Fork me on GitHub
#xtdb
<
2020-10-22
>
julienvincent22:10:25

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'}]

julienvincent22:10:34

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

jarohen22:10:18

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]}

julienvincent01:10:07

Thanks, I like that