Commit a9041a92a6c49e559f92906273acb8625607f4bb

Authored by Andrew Kane
1 parent f5f8aaf7

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

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