From ddc3a54471a8b9d18eb649cc93e395d3e1f73be6 Mon Sep 17 00:00:00 2001 From: Rustam Sharshenov Date: Fri, 7 Nov 2014 07:54:21 +0600 Subject: [PATCH] Revert "Include indexed search_data on demand" --- lib/searchkick/model.rb | 2 -- lib/searchkick/query.rb | 3 +-- lib/searchkick/results.rb | 26 +++++++++++--------------- 3 files changed, 12 insertions(+), 19 deletions(-) diff --git a/lib/searchkick/model.rb b/lib/searchkick/model.rb index ee3b76f..f2cad7a 100644 --- a/lib/searchkick/model.rb +++ b/lib/searchkick/model.rb @@ -7,8 +7,6 @@ module Searchkick class_eval do cattr_reader :searchkick_options, :searchkick_env, :searchkick_klass - attr_accessor :response_search_data - callbacks = options.has_key?(:callbacks) ? options[:callbacks] : true class_variable_set :@@searchkick_options, options.dup diff --git a/lib/searchkick/query.rb b/lib/searchkick/query.rb index 85299a7..a791028 100644 --- a/lib/searchkick/query.rb +++ b/lib/searchkick/query.rb @@ -328,7 +328,7 @@ module Searchkick # An empty array will cause only the _id and _type for each hit to be returned # http://www.elasticsearch.org/guide/reference/api/search/fields/ - if load and not options[:include_search_data] + if load payload[:fields] = [] elsif options[:select] payload[:fields] = options[:select] @@ -408,7 +408,6 @@ module Searchkick per_page: @per_page, padding: @padding, load: @load, - include_search_data: options[:include_search_data] || false, includes: options[:include] || options[:includes], json: !options[:json].nil? } diff --git a/lib/searchkick/results.rb b/lib/searchkick/results.rb index 30f11d6..79f1d1d 100644 --- a/lib/searchkick/results.rb +++ b/lib/searchkick/results.rb @@ -41,12 +41,19 @@ module Searchkick # sort hits.map do |hit| - result = results[hit["_type"]].find{|r| r.id.to_s == hit["_id"].to_s } - result.response_search_data = build_hashie_result hit if options[:include_search_data] and result - result + results[hit["_type"]].find{|r| r.id.to_s == hit["_id"].to_s } end.compact else - hits.map { |hit| build_hashie_result hit } + hits.map do |hit| + result = + if hit["_source"] + hit.except("_source").merge(hit["_source"]) + else + hit.except("fields").merge(hit["fields"]) + end + result["id"] ||= result["_id"] # needed for legacy reasons + Hashie::Mash.new(result) + end end end end @@ -136,16 +143,5 @@ module Searchkick @response["hits"]["hits"] end - def build_hashie_result hit - result = - if hit["_source"] - hit.except("_source").merge(hit["_source"]) - else - hit.except("fields").merge(hit["fields"]) - end - result["id"] ||= result["_id"] # needed for legacy reasons - Hashie::Mash.new(result) - end - end end -- libgit2 0.21.0