Fork me on GitHub
#datomic
<
2015-10-21
>
val_waeselynck10:10:24

@robert-stuttaford: I did the mocking stuff on my dev laptop, it takes on average 2ms to create a mock db and run one transaction on it simple_smile

val_waeselynck10:10:51

So yeah, good for testing.

thosmos18:10:43

@dsapoetra: what's your series of repl commands?

bostonaholic20:10:06

full-search is what's falling apart

jgdavey20:10:22

change or to or-join, naming all vars that need bound

jgdavey20:10:47

Looks like maybe just ?person in your case?

jgdavey20:10:36

@bostonaholic: Oh, I mean ?person and ?query

bostonaholic20:10:22

I've tried the or-join and it still doesn't work

bostonaholic20:10:26

well, at least I don't get the exception. But only Bob is returned

bostonaholic20:10:27

I updated the gist to use or-join

Ben Kamphaus20:10:01

works fine for me with clj re-pattern and your or-join

Ben Kamphaus20:10:11

(defn full-search [db query]
  (d/q '[:find [(pull ?person [* {:person/address [*]}]) ...]
         :in $ ?query
         :where
         (or-join [?person ?query]
          (and
               [?person :person/name ?name]
               [(re-find ?query ?name)])

          (and
               [?person :person/address ?address]
               [?address :address/street ?street]
               [(re-find ?query ?street)]))]
       db
       (re-pattern (str "(?i).*" query ".*"))))

jgdavey20:10:13

Looks like there’s a typo in your data

Ben Kamphaus20:10:59

Also gist contains a couple of tempid partition typos

Ben Kamphaus20:10:04

yeah ^ that one

jgdavey20:10:00

I just ran this with the typos fixed, and it does return the expected results (Bob and Charles)

jgdavey20:10:23

java version “1.8.0_20” and [com.datomic/datomic-pro “0.9.5302”]

Ben Kamphaus20:10:11

@bostonaholic can confirm what @jgdavey sees (working as expected), w/1.7.0_60 and 0.9.5327 — so I expect issue is in data.

bostonaholic20:10:51

YAY, it works!

bostonaholic20:10:28

thanks for your help @bkamphaus and @jgdavey

bostonaholic22:10:23

I've updated the gist with an added bit of complexity. Note that line #102 works, but #96 does not https://gist.github.com/bostonaholic/30e31f4620804632d3c8

bostonaholic22:10:23

(load-file "datomic-search.clj") works great for that file

thosmos23:10:36

@dsapoetra: these commands work as expected for me in the IntelliJ repl: (require '[datomic.api :as d]) (d/create-database "datomic:<free://localhost:4334/sample-database%22|free://localhost:4334/sample-database">) (d/connect "datomic:<free://localhost:4334/sample-database%22|free://localhost:4334/sample-database">)

jgdavey23:10:43

@bostonaholic: It seems like destructuring is tripping you up. Since you’re passing in an empty collection, the or-join cannot bind ?zip. The query will always return nothing.

jgdavey23:10:19

One way to get around this is to destructure the collection within an or-join.

jgdavey23:10:22

It’s probably not the most elegant way to do this, but it does work. Somebody else might be able to provide a more elegant way to destructure (i.e. without identity).

bostonaholic23:10:41

I like my (conj zips "") hack 😜

bostonaholic23:10:07

this is when I wish datomic was OSS so I could dig into the source to see if it's a bug, or a feature