Commit 1fe4784907a22cd02ac831df9ecb614586e53b6d
1 parent
2e655702
Exists in
master
and in
21 other branches
Use more efficient query if no facets
Showing
1 changed file
with
15 additions
and
3 deletions
Show diff stats
lib/searchkick/query.rb
... | ... | @@ -254,9 +254,21 @@ module Searchkick |
254 | 254 | # filters |
255 | 255 | filters = where_filters(options[:where]) |
256 | 256 | if filters.any? |
257 | - payload[:filter] = { | |
258 | - and: filters | |
259 | - } | |
257 | + if options[:facets] | |
258 | + payload[:filter] = { | |
259 | + and: filters | |
260 | + } | |
261 | + else | |
262 | + # more efficient query if no facets | |
263 | + payload[:query] = { | |
264 | + filtered: { | |
265 | + query: payload[:query], | |
266 | + filter: { | |
267 | + and: filters | |
268 | + } | |
269 | + } | |
270 | + } | |
271 | + end | |
260 | 272 | end |
261 | 273 | |
262 | 274 | # facets | ... | ... |