Fix full text search without quotes not working

Decoupled query-dsl from search/block-search. This coupling added
unnecessary complexity as srs, custom queries and the api all depend
on query-dsl and don't need to be coupled to search/block-search
This commit is contained in:
Gabriel Horner
2022-03-15 15:46:26 -04:00
committed by Tienson Qin
parent 6ca34f1430
commit e615423e6a
2 changed files with 35 additions and 38 deletions

View File

@@ -374,7 +374,7 @@ Some bindings in this fn:
([e env]
(build-query e (assoc env :vars (atom {})) 0))
([e {:keys [sort-by blocks? sample] :as env :or {blocks? (atom nil)}} level]
; {:post [(or (nil? %) (map? %))]}
; {:post [(or (nil? %) (map? %))]}
(let [fe (first e)
fe (when fe (symbol (string/lower-case (name fe))))
page-ref? (text/page-ref? e)]
@@ -498,31 +498,29 @@ Some bindings in this fn:
(let [s (if (= \# (first s)) (util/format "[[%s]]" (subs s 1)) s)
form (some-> s
(pre-transform)
(reader/read-string))]
(if (symbol? form)
(str form)
(let [sort-by (atom nil)
blocks? (atom nil)
sample (atom nil)
{result :query rules :rules}
(when form (build-query form {:sort-by sort-by
:blocks? blocks?
:sample sample}))
result' (when (seq result)
(let [key (if (coll? (first result))
(keyword (ffirst result))
(keyword (first result)))
result (case key
:and
(rest result)
(reader/read-string))
sort-by (atom nil)
blocks? (atom nil)
sample (atom nil)
{result :query rules :rules}
(when form (build-query form {:sort-by sort-by
:blocks? blocks?
:sample sample}))
result' (when (seq result)
(let [key (if (coll? (first result))
(keyword (ffirst result))
(keyword (first result)))
result (case key
:and
(rest result)
result)]
(add-bindings! form result)))]
{:query result'
:rules (mapv rules/query-dsl-rules rules)
:sort-by @sort-by
:blocks? (boolean @blocks?)
:sample sample})))
result)]
(add-bindings! form result)))]
{:query result'
:rules (mapv rules/query-dsl-rules rules)
:sort-by @sort-by
:blocks? (boolean @blocks?)
:sample sample})
(catch js/Error e
(log/error :query-dsl/parse-error e)))))