Skip to content

Commit

Permalink
[SE-6548] Do not create malformed Elasticsearch queries
Browse files Browse the repository at this point in the history
  • Loading branch information
jvia committed Oct 15, 2024
1 parent 3eb9cfc commit 2060119
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions src/com/nytimes/querqy/elasticsearch.clj
Original file line number Diff line number Diff line change
Expand Up @@ -124,13 +124,16 @@

BooleanQuery
(emit* [query {:keys [::parent] :as opts}]
(let [get-occur (comp m/occur->kw m/get-occur)
clauses (forv [clause (.getClauses query)]
(let [occur (get-occur clause)
clause (emit* clause opts)]
(hash-map occur (if (sequential? clause)
clause
(vector clause)))))
(let [clauses
(forv [clause (.getClauses query)]
(let [occur (case (m/occur->kw (m/get-occur clause))
:should :should
:must :must
:must-not :must_not)
clause (emit* clause opts)]
(hash-map occur (if (sequential? clause)
clause
(vector clause)))))
first-occur (keys (first clauses))
promotable #{:should :must}]
(cond
Expand Down Expand Up @@ -175,7 +178,7 @@
boost-up (forv [query (.getBoostUpQueries query)]
(emit* query opts))
boost-down (forv [^BoostQuery query (.getBoostDownQueries query)]
;; down boost are converted to negative numbers here
;; down boost are converted to negative numbers here
(let [boosted (m/boost-query (- (.getBoost query)) (.getQuery query))]
(emit* boosted opts)))
functions (concat boost-up boost-down)
Expand Down

0 comments on commit 2060119

Please # to comment.