Fork me on GitHub
#xtdb
<
2020-09-04
>
pbaille16:09:28

Hello! I'm trying the EQL projections with an exemple similar to the one in the documentation (I'm using "20.09-1.11.0-beta")

(crux/submit-tx node
                [[:crux.tx/put {:crux.db/id 1, :user/name "Ivan", :user/profession {:profession/name "Doctor"}}],
                 [:crux.tx/put {:crux.db/id 2, :user/name "Sergei", :user/profession {:profession/name "Lawyer"}}]
                 [:crux.tx/put {:crux.db/id 3, :user/name "Petr", :user/profession {:profession/name "Doctor"}}]])

(crux/q (crux/db node)
        '{:find [(eql/project ?user [:user/name {:user/profession [:profession/name]}])]
          :where [[?user :user/name ?uname]]})
but my query strangly evaluates to this: (the :user/profession is empty))
#{[#:user{:name "Ivan", :profession {}}]
  [#:user{:name "Petr", :profession {}}]
  [#:user{:name "Sergei", :profession {}}]}
Am I missing something ? Is it a bug ? Thank you 🙂

nivekuil16:09:36

your document structure is odd; presumably you want to store :user/profession "Doctor" and then on another document (think of it as a table) you might have some entity with :profession/name "Doctor" :profession/salary 10000 and you can access salary from within the [`:profession/name`] vec in your query

pbaille17:09:15

ok I understand! thank you 🙂

refset21:09:36

Hi again! So I think the issue here is that you are storing a map as a value and our current EQL implementation can't peek inside that map value. So with that existing doc structure you would have to do an update-in + select-keys from Clojure after the query results have been returned

👍 3
nivekuil16:09:39

it looks like crux can't store byte-arrays; that's kind of surprising, are those hard to index? specifically I'd like to store the sha256 hash buddy.core gives me

refset21:09:23

There's no particular reason why we can't support byte-array values, it's just not yet been a priority so far. You're not the first person to mention it though, (incidentally, also in relation to cryptographic keys!), so it is definitely on our radar. For the time being you can either wrap your byte-array inside a Java object (that Nippy can efficiently serialise), or you have to use base64

👍 3