Best effort glimpse
This commit is contained in:
@@ -7,6 +7,19 @@
|
||||
[datomic.api :as dc]
|
||||
[ring.middleware.json :refer [wrap-json-response]]))
|
||||
|
||||
(defn best-match [q]
|
||||
|
||||
(let [name-like-ids (when (not-empty q)
|
||||
(map (comp #(Long/parseLong %) :id)
|
||||
(solr/query solr/impl "vendors"
|
||||
{"query" (cond-> (format "name:(%s*)" (str/upper-case (solr/escape q)))
|
||||
true (str " hidden:false"))
|
||||
"fields" "id"
|
||||
"limit" 300})))
|
||||
valid-clients (for [n name-like-ids]
|
||||
{"value" n "label" (pull-attr (dc/db conn) :vendor/name n)})]
|
||||
(first valid-clients)))
|
||||
|
||||
(defn search [{:keys [clients query-params identity]}]
|
||||
|
||||
(let [name-like-ids (when (not-empty (get query-params "q"))
|
||||
|
||||
Reference in New Issue
Block a user