From a9041a92a6c49e559f92906273acb8625607f4bb Mon Sep 17 00:00:00 2001 From: Andrew Kane Date: Thu, 21 Mar 2019 09:35:58 -0700 Subject: [PATCH] Fixed issue with misspellings below and body block - closes #1244 --- CHANGELOG.md | 1 + lib/searchkick.rb | 2 +- lib/searchkick/query.rb | 5 ++++- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3bacd88..acdf451 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ - Added support for endless ranges - Added `prefix` to `where` - Fixed error with some language stemmers and Elasticsearch 6.5 +- Fixed issue with misspellings below and body block ## 3.1.2 diff --git a/lib/searchkick.rb b/lib/searchkick.rb index bee1e1c..44753c6 100644 --- a/lib/searchkick.rb +++ b/lib/searchkick.rb @@ -91,8 +91,8 @@ module Searchkick end end + options = options.merge(block: block) if block query = Searchkick::Query.new(klass, term, options) - block.call(query.body) if block if options[:execute] == false query else diff --git a/lib/searchkick/query.rb b/lib/searchkick/query.rb index c4d981e..c637db0 100644 --- a/lib/searchkick/query.rb +++ b/lib/searchkick/query.rb @@ -15,7 +15,7 @@ module Searchkick :out_of_range?, :hits, :response, :to_a, :first def initialize(klass, term = "*", **options) - unknown_keywords = options.keys - [:aggs, :body, :body_options, :boost, + unknown_keywords = options.keys - [:aggs, :block, :body, :body_options, :boost, :boost_by, :boost_by_distance, :boost_by_recency, :boost_where, :conversions, :conversions_term, :debug, :emoji, :exclude, :execute, :explain, :fields, :highlight, :includes, :index_name, :indices_boost, :limit, :load, :match, :misspellings, :model_includes, :offset, :operator, :order, :padding, :page, :per_page, :profile, @@ -483,6 +483,9 @@ module Searchkick # merge more body options payload = payload.deep_merge(options[:body_options]) if options[:body_options] + # run block + options[:block].call(payload) if options[:block] + @body = payload @page = page @per_page = per_page -- libgit2 0.21.0