Fork me on GitHub

I want to find all documents with a certain :crux.db/id prefix, what is the best practice? Ie (crux/q (crux/db node) '{:find [?e] :where [[?e :crux.db/id ?id] [(clojure.string/starts-with? ?id ":myprefix")]]})


Hi @U5JQAQE4X! Unfortunately there is no way to do this efficiently - is there a reason why you can't introduce a new attribute?


I think I have a attribute which works already, thanks for the idea! I just am doing some greenfield / hobby work with Crux and wanted to understand how to interact, so this helps


Ah okay, no problem - good question! :)


is it something that would work on Datomic though?


@UECLGBLES hey! I think with Datomic you could use the raw AVE index to jump straight to a prefix range and retrieve a set of db.unique/identity values. An equivalent is not currently possible in Crux due to: 1) keywords are hashed in the indexes so such values (including usage as :crux.db/id) won't end up sorted alphanumerically (see codec.clj) 2) you cannot access the the raw indexes - even if you could there could well be a lot more processing cost required than with Datomic due to the extra time dimension (depending on the shape and size of your data history)

✔️ 4

thanks for the reply!

🙂 4