Skip to content

Commit e0ce412

Browse files
committed
Updates
1 parent f627edf commit e0ce412

File tree

3 files changed

+81
-70
lines changed

3 files changed

+81
-70
lines changed

src/com/nytimes/querqy/elasticsearch.clj

+2-3
Original file line numberDiff line numberDiff line change
@@ -163,9 +163,8 @@
163163
boost-up (forv [query (.getBoostUpQueries query)]
164164
(emit* query opts))
165165
boost-down (forv [^BoostQuery query (.getBoostDownQueries query)]
166-
;; down boost are converted to negative numbers here
167-
(let [boosted (m/boost-query {:boost (- (.getBoost query))
168-
:query (.getQuery query)})]
166+
;; down boost are converted to negative numbers here
167+
(let [boosted (m/boost-query (- (.getBoost query)) (.getQuery query))]
169168
(emit* boosted opts)))
170169
functions (concat boost-up boost-down)
171170
default-query {:function_score {:query user-query, :functions []}}]

src/com/nytimes/querqy/model.clj

+3-4
Original file line numberDiff line numberDiff line change
@@ -108,8 +108,7 @@
108108

109109
(extend-protocol cp/Datafiable
110110
MatchAllQuery
111-
(datafy [^BoostedTerm t]
112-
{:match_all {}}))
111+
(datafy [_] {:match_all {}}))
113112

114113
;; ----------------------------------------------------------------------
115114
;; DisjunctionMaxQuery
@@ -193,8 +192,8 @@
193192
QuerqyQuery
194193
(clone [_ new-parent]
195194
(RawQuery. new-parent occur query generated?))
196-
(clone [_ new-parent generated?]
197-
(RawQuery. new-parent occur query generated?)))
195+
(clone [_ new-parent generated'?]
196+
(RawQuery. new-parent occur query generated'?)))
198197

199198
(defn rawq? [obj] (instance? RawQuery obj))
200199

test/com/nytimes/querqy/commonrules_test.clj

+76-63
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
[clojure.test :refer [deftest is]]
77
[com.nytimes.querqy :as querqy]
88
[com.nytimes.querqy.commonrules :as r :refer [boost delete filter match match* synonym]]
9-
[com.nytimes.querqy.model :refer :all]
109
[testit.core :refer [=> =in=> facts]])
1110
(:import
1211
(querqy.rewrite.commonrules.select.booleaninput BooleanInputParser)
@@ -129,68 +128,82 @@
129128
=> {:query {:should [#{{:term "A5"}}]},
130129
:boost [{:query {:must [#{{:term "B5"}}]}, :boost 2.0}]})
131130

132-
#_(facts "A6"
133-
(rewrite resource-rewriter "A6")
134-
=> {}
135-
136-
(rewrite dsl-rewriter "A6")
137-
=> {})
138-
139-
#_(facts "A7 B7"
140-
(rewrite resource-rewriter "A7 B7")
141-
=> {}
142-
143-
(rewrite dsl-rewriter "A7 B7")
144-
=> {})
145-
146-
#_(facts "A8"
147-
(rewrite resource-rewriter "A8")
148-
=> {}
149-
150-
(rewrite dsl-rewriter "A8")
151-
=> {})
152-
153-
#_(facts "A9"
154-
(rewrite resource-rewriter "A9")
155-
=> {}
156-
157-
(rewrite dsl-rewriter "A9")
158-
=> {})
159-
160-
#_(facts "A10 B10"
161-
(rewrite resource-rewriter "A10 B10")
162-
=> {}
163-
164-
(rewrite dsl-rewriter "A10 B10")
165-
=> {})
166-
167-
#_(facts "A11"
168-
(rewrite resource-rewriter "A11")
169-
=> {}
170-
171-
(rewrite dsl-rewriter "A11")
172-
=> {})
173-
174-
#_(facts "A11 B11"
175-
(rewrite resource-rewriter "A11 B11")
176-
=> {}
177-
178-
(rewrite dsl-rewriter "A11 B11")
179-
=> {})
180-
181-
#_(facts "best netflix show"
182-
(rewrite resource-rewriter "best netflix show")
183-
=> {}
184-
185-
(rewrite dsl-rewriter "best netflix show")
186-
=> {})
187-
188-
#_(facts "best amazon show"
189-
(rewrite resource-rewriter "best amazon show")
190-
=> {}
191-
192-
(rewrite dsl-rewriter "best amazon show")
193-
=> {}))
131+
(facts "A6"
132+
(rewrite resource-rewriter "A6")
133+
=> {:query {:should [#{{:term "A6"}}]},
134+
:filter [{:must [#{{:term "B6"}}]}]}
135+
136+
(rewrite dsl-rewriter "A6")
137+
=> {:query {:should [#{{:term "A6"}}]},
138+
:filter [{:must [#{{:term "B6"}}]}]})
139+
140+
(facts "Terms may be deleted: A7 B7"
141+
(rewrite resource-rewriter "A7 B7")
142+
=> {:query {:should [#{{:term "A7"}}]}}
143+
144+
(rewrite dsl-rewriter "A7 B7")
145+
=> {:query {:should [#{{:term "A7"}}]}})
146+
147+
(facts "A8"
148+
(rewrite resource-rewriter "A8")
149+
=> {:query {:should [#{{:term "B8"} {:term "A8"}}]},
150+
:boost [{:query {:must [#{{:term "C8"}}]}, :boost 2.0}]}
151+
152+
(rewrite dsl-rewriter "A8")
153+
=> {:query {:should [#{{:term "B8"} {:term "A8"}}]},
154+
:boost [{:query {:must [#{{:term "C8"}}]}, :boost 2.0}]})
155+
156+
(facts "A9"
157+
(rewrite resource-rewriter "A9")
158+
=> {:query {:should [#{{:term "A9"}}]},
159+
:boost [{:query {:must [#{{:term "C9"}}]}, :boost 2.0}]}
160+
161+
(rewrite dsl-rewriter "A9")
162+
=> {:query {:should [#{{:term "A9"}}]},
163+
:boost [{:query {:must [#{{:term "C9"}}]}, :boost 2.0}]})
164+
165+
(facts "A10 B10"
166+
(rewrite resource-rewriter "A10 B10")
167+
=> {:query {:should [#{{:term "A10"}} #{{:term "B10"}}]},
168+
:boost [{:query {:must [#{{:term "C10"}}]}, :boost 2.0}]}
169+
170+
(rewrite dsl-rewriter "A10 B10")
171+
=> {:query {:should [#{{:term "A10"}} #{{:term "B10"}}]},
172+
:boost [{:query {:must [#{{:term "C10"}}]}, :boost 2.0}]})
173+
174+
(facts "A11"
175+
(rewrite resource-rewriter "A11")
176+
=> {:query {:should [#{{:term "A11"}}]},
177+
:boost [{:query {:must [#{{:term "C11"}}]}, :boost 2.0}]}
178+
179+
(rewrite dsl-rewriter "A11")
180+
=> {:query {:should [#{{:term "A11"}}]},
181+
:boost [{:query {:must [#{{:term "C11"}}]}, :boost 2.0}]})
182+
183+
(facts "A11 B11"
184+
(rewrite resource-rewriter "A11 B11")
185+
=> {:query {:should [#{{:term "A11"}} #{{:term "B11"}}]}}
186+
187+
(rewrite dsl-rewriter "A11 B11")
188+
=> {:query {:should [#{{:term "A11"}} #{{:term "B11"}}]}})
189+
190+
(facts "best netflix show"
191+
(rewrite resource-rewriter "best netflix show")
192+
=> {:query {:should [#{{:term "best"}} #{{:term "netflix"}} #{{:term "show"}}]},
193+
:boost [{:query {:must [#{{:term "netflix"}}]}, :boost 2.0}]}
194+
195+
(rewrite dsl-rewriter "best netflix show")
196+
=> {:query {:should [#{{:term "best"}} #{{:term "netflix"}} #{{:term "show"}}]},
197+
:boost [{:query {:must [#{{:term "netflix"}}]}, :boost 2.0}]})
198+
199+
(facts "best amazon show"
200+
(rewrite resource-rewriter "best amazon show")
201+
=> {:query {:should [#{{:term "best"}} #{{:term "amazon"}} #{{:term "show"}}]},
202+
:boost [{:query {:must [#{{:term "amazon"}}]}, :boost 2.0}]}
203+
204+
(rewrite dsl-rewriter "best amazon show")
205+
=> {:query {:should [#{{:term "best"}} #{{:term "amazon"}} #{{:term "show"}}]},
206+
:boost [{:query {:must [#{{:term "amazon"}}]}, :boost 2.0}]}))
194207

195208
;; Custom Functions
196209

0 commit comments

Comments
 (0)