Fork me on GitHub
#xtdb
<
2022-01-27
>
dvorme00:01:08

Has anyone here loaded (or considered loading) Clojure source into XTDB and used XTDB as a search/filtering engine? Thoughts?

refset00:01:54

I've certainly considered it many times...but not shipped anything 🙂 I know @U04V5V0V4 has been building in this space very recently: https://github.com/repl-acement/repl-acement (though I can't see that there's any persistence working yet, XT or otherwise)

genRaiy08:01:03

@U899JBRPF it's next on the todo list

🙂 2
👀 1
sb09:01:53

Is that possible reset the full rocksdb (dev environment) from Clojure (xtdb api)? (I can’t find in the documentation)

malcolmsparks10:01:26

If you want do that you'll lose all your data, but if that's what you want go ahead. There isn't a programmatic way to do that, at least not via the XTDB API.

👍 1
malcolmsparks10:01:52

If you delete only your indices they will get recreated on startup.

👍 1
sb16:01:09

thanks the infos!

Pragyan Tripathi15:01:13

I am trying to write an XTDB query… My use case requires me to fetch list of all ids for a given entity. Following code doesn’t work…

(defn exec-query
  [env {:adapter/keys [type id]} entity-id]
  (let [node (get-in env [type id :node])
        db (xt/db node)
        result (xt/q db
                     '{:find [(pull ?entity [*])]
                       :in [eid]
                       :where [[?entity eid _]]}
                     entity-id)]
    (tap> result)
    []))
when I hardcode the attribute place it works. and I get list of all ids for datasource entity.
(defn exec-query
  [env {:adapter/keys [type id]} entity-id]
  (let [node (get-in env [type id :node])
        db (xt/db node)
        result (xt/q db
                     '{:find [(pull ?entity [*])]
                       
                       :where [[?entity :datasource/id _]]}
                     )]
    (tap> result)
    []))
I have multiple entities like this, I was hoping how can use entity-id variable to do this task. On reading the documentation https://docs.xtdb.com/language-reference/1.20.0/datalog-queries/#_edn_datalog I realized this is not allowed. Is there any way I can generate this query and use it.

refset15:01:44

Hi Pragyan, that's right, attributes in the triple clauses can't be "dynamic" like that, as the query planner needs to know which attributes are being used. However you can certainly dynamically generate new queries, by manipulating the edn symbolically, e.g.

(defn exec-query
  [env {:adapter/keys [type id]} entity-id]
  (let [node (get-in env [type id :node])
        db (xt/db node)
        result (xt/q db
                     {:find '[(pull ?entity [*])]
                      :where [['?entity entity-id '_]]})]
    (tap> result)
    []))

Steven Deobald15:01:21

@U02JRAM6CBA This is a sufficiently common question that it might help others to see it in a public place. If you have time, it would be great if you could cross-post it to http://discuss.xtdb.com (no pressure, of course)

Pragyan Tripathi15:01:52

@U899JBRPF Thank you so much… I was struggling with quoting the correct symbol… this works falwlessly… @U01AVNG2XNF Sure will do…

🙂 2
refset15:01:55

Awesome, thanks for that @U02JRAM6CBA

👍 1