datomic

Ask questions on the official Q&A site at https://ask.datomic.com!
Pragyan Tripathi 2021-05-12T03:49:58.086300Z

Thanks this helps.

💯 1
Joe Lane 2021-05-12T03:53:37.086600Z

Check out http://www.learndatalogtoday.org/

👍 1
🎉 2
enn 2021-05-12T16:41:22.093Z

I’m trying to understand the use of the tx-data function in queries. The docs (https://docs.datomic.com/on-prem/api/log.html#log-in-query) give this example: [(tx-data ?log ?tx) [[?e ?a ?v _ ?op]]] That works for me as expected. But I was hoping to be able to provide values for some of those slots, like so: [(tx-data ?log ?tx-id) [[?e :label/public-id ?v _ false]]] This gives me results I don’t understand. ?v gets bound to an entity, not a value--specifically, the entity to which I’d expect ?e to be bound. ?e gets bound to another entity (an entity which definitely does not have a :label/public-id attr) which I wouldn’t expect to be in this datom at all.

favila 2021-05-12T16:44:20.093100Z

I’m a little surprised this works at all. The ?a slot here is a number (an entity id), so I would expect :label/public-id to cause the binding to never unify with anything.

favila 2021-05-12T16:49:42.093400Z

I think this should work as you expect

[(datomic.api/entid $ :label/public-id) ?label-public-id-attr]
[(tx-data ?log ?tx-id) [[?e ?label-public-id-attr ?v _ false]]]

enn 2021-05-12T16:50:07.093600Z

thanks, I think that will work. I agree that it’s weird that it returns anything the other way.

jdkealy 2021-05-12T21:07:10.094900Z

is there a limit on how many records i can run (fulltext on ? I have a list of 46k users and datomic seems to be dying on calling fulltext on their names

Joe Lane 2021-05-12T21:10:10.095300Z

What is the full query?

jdkealy 2021-05-12T21:11:55.095600Z

{:find [[?e ...]],
   :in [$ ?lname],
   :where [[?e :ent/type "user"]
           [(fulltext $ :user/name ?lname) [[?e _ _ _]]]]}

Joe Lane 2021-05-12T21:14:14.096Z

And what happens when you remove [?e :ent/type "user"]?

jdkealy 2021-05-12T21:40:28.096200Z

same

jdkealy 2021-05-12T22:25:18.096400Z

wait actually... no it's fast now

jdkealy 2021-05-12T22:28:01.096600Z

i don't understand why

Joe Lane 2021-05-12T23:06:11.096800Z

1. Find all entities ?e that have an :ent/type 2. Limit the ?e's to only those that have an :ent/type of "user" 3. Find entities that have a :user/name of ?lname and and then bind them to ?e 4. Join ?e's from both results to limit the result set further 5. Take all the resulting ?e's and return a collection of them

Joe Lane 2021-05-12T23:06:35.097Z

^^ That's what your first query did

Joe Lane 2021-05-12T23:08:15.097200Z

You could probably flip those two :where clauses around and it would work great. The number of ?e's returned by [?e :ent/type "user"] is probably much larger than those returned by the fulltext clause.