Fork me on GitHub

having trouble with quoting and function calls inside a query. how could I make this work?

(q '{:find  [?e ?s ?r]
     :where [[?e :snippet ?s]
             [?e :result ?r]
             [(clojure.string/includes? ?s ?search-string) ?s-match]
             [(clojure.string/includes? ?r ?search-string) ?r-match]
             [(or ?s-match ?r-match) ?match]]
     :args  [{:?search-string "range"}]})


solved it with

(defn some-strings-include? [q & strings]
  (boolean (some #(str/includes? % q) strings)))

(defn crux-search [q-str]
 (q {:find  '[?e ?s ?r ]
     :where '[[?e :snippet ?s]
              [?e :result ?r]
              [(some-strings-include? ?search-string ?s ?r) ?match]]
     :args  [{:?search-string q-str}]}))


Hey @U050CJFRU sorry I wasn't responsive for this. I'm glad you figured it out okay though! Which example did you find most helpful for working it out?


thanks @U899JBRPF this from the docs helped > Note that many of these not yet supported query features can be achieved via simple function calls since you can currently fully qualify any function that is loaded. In future, limitations on available functions may be introduced to enforce security restrictions for remote query execution.


Cool, good to know! I will see if I can make this more prominent somehow.


Is there a way to query tx-time or valid-time? This doesn't work:

{:find  '[?e ?s ?r ?t]
 :where '[[?e :snippet ?s]
          [?e :result ?r]
          [?e :crux.db/valid-time ?t]   ; <------------
          [(some-strings-include? ?search-string ?s ?r) ?match]]
 :args  [{:?search-string "test"}]}


Queries can't access this information about the db context, i.e the valid time and transaction time coordinate used to generate the context


I don't see how you could incorporate transaction time into your documents / queries, however you can certainly include additional timestamp keys in your documents that match the valid time


These are then just regular attributes (and could support standard range queries), but you would probably want to be careful to keep them synchronised with valid time coordinates somehow as the documents get re-inserted

denik00:06:44;cid=CG3AM2F7V that's what I'm doing but it feels superfluous. is this a technical limitation or a design decision. if its the latter, see question above 🙂