Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SE-6548] Do not create malformed Elasticsearch queries #12

Merged
merged 1 commit into from
Oct 15, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading