Skip to content

Instantly share code, notes, and snippets.

@jvia
Created December 20, 2021 21:51
Show Gist options
  • Save jvia/564f40d87b8d41e409d6d936ade1f345 to your computer and use it in GitHub Desktop.
Save jvia/564f40d87b8d41e409d6d936ade1f345 to your computer and use it in GitHub Desktop.
querqy clojure example
;; define a rule base
(defrules rules
(match "personal computer"
(synonym "pc")
(synonym "desktop computer")
(down 50 "software"))
(match "sofa*"
(synonym "sofa *1")))
;; take the query "sofabed" and generate an ES query
;; based on the rule base
(-> (rewrite rules "sofabed")
(emit-query {:default-field :textAll}))
{:bool
{:should [{:match {:textAll "sofabed"}}
{:match {:textAll "sofa bed"}}]}}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment