Fork me on GitHub
#datomic
<
2018-01-13
>
Drew Verlee02:01:50

Can someone help me understand why

(def schema {:cli {:db/cardinality :db.cardinality/many}})
(d/transact! conn [{:name "foo" :type :cli} {:name "bar" :type :cli}])

(d/q '[:find (pull ?e [:name])
       :where
       [?e :type :cli]]
     @conn)

;;([{:name "bar"}] [{:name "foo"}])
Returns a list of vectors rather then a list of maps? e.g
({:name "bar"} {:name "foo"})

val_waeselynck11:01:59

@U0DJ4T5U1 By default, Datalog always returns a collection of tuples. If you want a list instead, wrap your pull pattern in [ ...]; if you want a single result, add a . after the pull pattern.

Drew Verlee21:01:20

Thanks @U06GS6P1N. Thats right on point, with what i wanted. There are a lot of docs to comb over for datomic

val_waeselynck10:01:31

@U0DJ4T5U1 You're welcome. What does 'comb over' mean in English?

cjsauer14:01:48

@U06GS6P1N "comb over" in this context is like to search through, to read through. I think the best and most hilarious way to understand is by watching this clip from Spaceballs: https://www.youtube.com/watch?v=hD5eqBDPMDg

caleb.macdonaldblack09:01:09

I’m trying out the fulltext in datomic and it looks like it only matches whole words?

caleb.macdonaldblack09:01:28

like if I search “White” then a result like “Sam White” will return

caleb.macdonaldblack09:01:57

but if I search “Whit” Than “Sam White” does not return. Am I doing something wrong?

caleb.macdonaldblack09:01:13

Can I get datomic to return results that are parts of words?

val_waeselynck12:01:17

I generally agree with what Stuart Halloway said in this post - if you want powerful search, just send the data to a specialized store like ElasticSearch, with Datomic this is unusually easy to do thanks to facilities like the Log API and tx report queue.

conan14:01:03

I've done this with elasticsearch in the past and it's a breeze - but don't forget that your elasticsearch queries are likely to be an order of magnitude slower than your datomic ones, because your app doesn't have the elasticsearch data in memory.

caleb.macdonaldblack20:01:36

Thanks guys. In the end I created a predicated that concatenated all the fields I wanted to search on and used a regex.