Open Time Store™
Copyright © JUXT LTD 2018-2019

Introduction

This guide contains simple steps showing how to transact data and run a simple query. However, there are a few topics you might benefit from learning about before you get too far with attempting to use Crux:

  • EDN – the extensible data notation format used throughout the Crux APIs, see Essential EDN for Crux.

  • The Datalog query language – Crux supports an EDN-flavoured version of Datalog. The Queries section within this documentation provides a good overview. You can also find an interactive tutorial for EDN-flavoured Datalog here.

  • Clojure – whilst a complete Java API is provided, a basic understanding of Clojure is recommended – Clojure is a succinct and pragmatic data-oriented language with strong support for immutability and parallelism. See Clojure.org.

Setting Up

If you want to start interacting with Crux in your environment then it is advised you run Crux in a standalone configuration.

Alternatively, if you simply want to experiment with Crux using a demo Docker container from Docker Hub (no JVM/JDK/Clojure install required, only Docker!) then please see the standalone webservice example. You can also use this self-contained demonstration image to experiment with the REST API.

Transacting

(crux/submit-tx
 system
 [[:crux.tx/put :dbpedia.resource/Pablo-Picasso ; id for Kafka
   {:crux.db/id :dbpedia.resource/Pablo-Picasso ; id for Crux
    :name "Pablo"
    :last-name "Picasso"}
   #inst "2018-05-18T09:20:27.966-00:00"]]) ; valid time

Note that the ID for the Kafka transaction and the ID within the Crux document must be the same. Restating the ID within the Crux document is currently necessary although this may change in the future, as the standard API evolves.

Querying

(crux/q (crux/db system)
       '{:find [e]
         :where [[e :name "Pablo"]]})

You should get:

  #{[:dbpedia.resource/Pablo-Picasso]}

An entity query would be:

(crux/entity (crux/db system) :dbpedia.resource/Pablo-Picasso)

You should get:

  {:crux.db/id :dbpedia.resource/Pablo-Picasso
   :name "Pablo"
   :last-name "Picasso"}

Next Steps

Now you know the basics of how to interact with Crux you may want to dive into a REPL-based tutorial (or use the interactive no-install browser-based Nextjournal edition!). Otherwisethe next sensible thing to read about are the kinds of things you are able to do with Queries.