This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-02-10
Channels
- # announcements (6)
- # architecture (2)
- # babashka (30)
- # beginners (90)
- # calva (21)
- # cider (22)
- # clj-kondo (27)
- # cljs-dev (7)
- # clojure (132)
- # clojure-europe (51)
- # clojure-nl (12)
- # clojure-norway (3)
- # clojure-spec (3)
- # clojure-uk (5)
- # clojurescript (69)
- # cloverage (9)
- # conjure (5)
- # core-async (54)
- # cursive (14)
- # datomic (34)
- # emacs (7)
- # fulcro (10)
- # graalvm (40)
- # graalvm-mobile (2)
- # gratitude (2)
- # improve-getting-started (1)
- # introduce-yourself (1)
- # jobs-discuss (61)
- # leiningen (5)
- # malli (6)
- # off-topic (59)
- # pathom (11)
- # polylith (38)
- # reagent (3)
- # reitit (3)
- # rewrite-clj (3)
- # shadow-cljs (53)
- # tools-build (35)
- # transit (8)
- # vim (62)
- # web-security (26)
- # xtdb (4)
Hello there, need some help on querying composite keys in xtdb, my xt/id
are composed of say {:attr-1 "foo", :attr-2 :bar}
, say query:
{:find [?f]
:where [[?e :my/type :foo-bar]
[?e :xt/id ?f]]}
Returns:
#{... [{:attr-1 "foo" :attr-2 :bar}] ...}
And I need to filter/subquery these by their :attr-1
in :xt/id
, I've been adding a where [?f :attr-1 ?g]
and pulling ?g
in find:
{:find [?g]
:in [?lookup-attr-1]
:where [[?e :my/type :foo-bar]
[?e :xt/id ?f]
[?g :attr-1 ?lookup-attr-1]]}
but this results in an empty set, there aren't many docs on destructuring that I could find so this became kind of a pain 😕Did not try, I think last clause needs change. The format is for entity/attribute/value triple, your key is not an entity. You need use a function to check if id has :attr-1 as specified value
👍 1
You can get at the attributes in the map key by binding them - nested maps are not indexed:
XTDB only indexes top-level attributes in a document, so to avoid indexing certain attributes, one can currently move them down into a nested map, as nested values aren't indexed
(https://docs.xtdb.com/resources/faq/#technical)
{:find '[?f first-attr]
:where '[[?e :my/type :foo-bar]
[?e :xt/id ?f]
[(get ?f :attr-1) first-attr]}
👀 1
✔️ 2