Fork me on GitHub

Hi guys, I'm new to crux and Clojure (btw, loving both, great work) and I'm struggling with initializing Crux node with Kafka topology from Java. Everything works as expected I even get documents into Kafka if I leave crux.kv/db-dir default (not setting it). However I would like to use the same index db dir eac time but I'm unable to get it working if I put this into my config:

static {
        Clojure.var("clojure.core", "require")

        final String nodeConfig = "{:crux.node/topology [crux.kafka/topology crux.kv.rocksdb/kv-store]\n" +
            ":crux.kafka/bootstrap-servers \"localhost:9092\"\n" +
            ":crux.kv/db-dir ( \"/tmp/crux-store\" \"indexes\")" +

        node = Crux.startNode((Map<Keyword, ?>);
        node.sync(Duration.ofSeconds(30)); // Become consistent for a max of 30s
The exception is:
Caused by: java.lang.IllegalArgumentException: Arg :crux.kv/db-dir invalid: nil - failed: (instance? java.nio.file.Path %) spec: :crux.config/path
The same initialization config works if I'm using Clojure. Can someone give me a hint how to initialize file in the config please.

👀 3

first thing I'd try would be to pass the file as a raw string instead, just in case it's the part going wrong - ":crux.kv/db-dir \"/tmp/crux-store/indexes\""?


It seems that I overcomplicated it...exactly


just tried this: ":crux.kv/db-dir \"/tmp/crux-storage/indexes\"" + an it works.


Thank you @U050V1N74. I needed to take a break, to try the simplest option 😅


no worries - often the way 🙂


while I'm here.. can I ask you another question @U050V1N74 regarding upcoming functionalities. I'm translating some Cypher (Neo4j) queries into Crux/Datalog and I'm looking for equivalent of OPTIONAL MATCH which is in fact an OUTER JOIN. If I understand correctly this could be achieved by get-else which is not yet supported by Crux ATM. Is there any road map on this? I couldn't find any Github issue/task on this matter. Could I achieve "outer join" in any other way? Possibly by custom predicate function call as the docs suggests.


it's currently an internal implementation detail, so might change between releases - but you could try get-attr

{:find [name]
 :where [[e :crux.db/id :foo]
         [(get-attr e :name "default") name]]}


Thanks! will do.


I should say - "default" is optional - you can leave it out and it'll return null instead

👍 3