Commit a9041a92a6c49e559f92906273acb8625607f4bb

Authored by Andrew Kane
1 parent f5f8aaf7

Fixed issue with misspellings below and body block - closes #1244

CHANGELOG.md
... ... @@ -3,6 +3,7 @@
3 3 - Added support for endless ranges
4 4 - Added `prefix` to `where`
5 5 - Fixed error with some language stemmers and Elasticsearch 6.5
  6 +- Fixed issue with misspellings below and body block
6 7  
7 8 ## 3.1.2
8 9  
... ...
lib/searchkick.rb
... ... @@ -91,8 +91,8 @@ module Searchkick
91 91 end
92 92 end
93 93  
  94 + options = options.merge(block: block) if block
94 95 query = Searchkick::Query.new(klass, term, options)
95   - block.call(query.body) if block
96 96 if options[:execute] == false
97 97 query
98 98 else
... ...
lib/searchkick/query.rb
... ... @@ -15,7 +15,7 @@ module Searchkick
15 15 :out_of_range?, :hits, :response, :to_a, :first
16 16  
17 17 def initialize(klass, term = "*", **options)
18   - unknown_keywords = options.keys - [:aggs, :body, :body_options, :boost,
  18 + unknown_keywords = options.keys - [:aggs, :block, :body, :body_options, :boost,
19 19 :boost_by, :boost_by_distance, :boost_by_recency, :boost_where, :conversions, :conversions_term, :debug, :emoji, :exclude, :execute, :explain,
20 20 :fields, :highlight, :includes, :index_name, :indices_boost, :limit, :load,
21 21 :match, :misspellings, :model_includes, :offset, :operator, :order, :padding, :page, :per_page, :profile,
... ... @@ -483,6 +483,9 @@ module Searchkick
483 483 # merge more body options
484 484 payload = payload.deep_merge(options[:body_options]) if options[:body_options]
485 485  
  486 + # run block
  487 + options[:block].call(payload) if options[:block]
  488 +
486 489 @body = payload
487 490 @page = page
488 491 @per_page = per_page
... ...