Fork me on GitHub

Hi! I am currently evaluating crux for a use-case at my company on recommendation by Alexis (Keplar16). This is some really cool tech! I do have a small question: is it possible to query on nested maps? For example:

[[:a :labels {:x 'true' :z 'false'}]]
is there a way to query for labels -> x without flattening things into the form:
[[:a :labels/x 'true']
 [{:a :labels/z 'false'}]


The reason I ask is I want to be able to project all possible labels on a document, which would, perhaps naively, require me to store the labels as a map in addition to the flattened keys


Hey @U940MBY3T 🙂 Crux doesn't index map values in this way, but if you're looking to query for labels it might be worth using a set - you can then query for set membership:

(crux/submit-tx (crux-node)
                [[:crux.tx/put {:crux.db/id :a
                                :labels #{:x :y}}]])

(crux/q (crux/db (crux-node))
        '{:find [?e]
          :where [[?e :label :x]]})

;; => #{[:a]}


Thanks, I like that