Commit 0b161d2a3d169143ecc75b9450150fb48aa63b1e

Authored by Andrew Kane
1 parent 0deda243

Fixed error with exclude in certain cases for Elasticsearch 7.7

Showing 2 changed files with 6 additions and 1 deletions   Show diff stats
CHANGELOG.md
  1 +## 4.3.1 (unreleased)
  2 +
  3 +- Fixed error with `exclude` in certain cases for Elasticsearch 7.7
  4 +
1 5 ## 4.3.0 (2020-02-19)
2 6  
3 7 - Fixed `like` queries with `"` character
... ...
lib/searchkick/query.rb
... ... @@ -574,7 +574,8 @@ module Searchkick
574 574  
575 575 def build_query(query, filters, should, must_not, custom_filters, multiply_filters)
576 576 if filters.any? || must_not.any? || should.any?
577   - bool = {must: query}
  577 + bool = {}
  578 + bool[:must] = query if query
578 579 bool[:filter] = filters if filters.any? # where
579 580 bool[:must_not] = must_not if must_not.any? # exclude
580 581 bool[:should] = should if should.any? # conversions
... ...