Commit ddc3a54471a8b9d18eb649cc93e395d3e1f73be6
1 parent
b7e366a9
Exists in
master
and in
21 other branches
Revert "Include indexed search_data on demand"
This reverts commit b7e366a9dcd4ea72c3b53e46666465a4cd64c351.
Showing
3 changed files
with
12 additions
and
19 deletions
Show diff stats
lib/searchkick/model.rb
@@ -7,8 +7,6 @@ module Searchkick | @@ -7,8 +7,6 @@ module Searchkick | ||
7 | class_eval do | 7 | class_eval do |
8 | cattr_reader :searchkick_options, :searchkick_env, :searchkick_klass | 8 | cattr_reader :searchkick_options, :searchkick_env, :searchkick_klass |
9 | 9 | ||
10 | - attr_accessor :response_search_data | ||
11 | - | ||
12 | callbacks = options.has_key?(:callbacks) ? options[:callbacks] : true | 10 | callbacks = options.has_key?(:callbacks) ? options[:callbacks] : true |
13 | 11 | ||
14 | class_variable_set :@@searchkick_options, options.dup | 12 | class_variable_set :@@searchkick_options, options.dup |
lib/searchkick/query.rb
@@ -328,7 +328,7 @@ module Searchkick | @@ -328,7 +328,7 @@ module Searchkick | ||
328 | 328 | ||
329 | # An empty array will cause only the _id and _type for each hit to be returned | 329 | # An empty array will cause only the _id and _type for each hit to be returned |
330 | # http://www.elasticsearch.org/guide/reference/api/search/fields/ | 330 | # http://www.elasticsearch.org/guide/reference/api/search/fields/ |
331 | - if load and not options[:include_search_data] | 331 | + if load |
332 | payload[:fields] = [] | 332 | payload[:fields] = [] |
333 | elsif options[:select] | 333 | elsif options[:select] |
334 | payload[:fields] = options[:select] | 334 | payload[:fields] = options[:select] |
@@ -408,7 +408,6 @@ module Searchkick | @@ -408,7 +408,6 @@ module Searchkick | ||
408 | per_page: @per_page, | 408 | per_page: @per_page, |
409 | padding: @padding, | 409 | padding: @padding, |
410 | load: @load, | 410 | load: @load, |
411 | - include_search_data: options[:include_search_data] || false, | ||
412 | includes: options[:include] || options[:includes], | 411 | includes: options[:include] || options[:includes], |
413 | json: !options[:json].nil? | 412 | json: !options[:json].nil? |
414 | } | 413 | } |
lib/searchkick/results.rb
@@ -41,12 +41,19 @@ module Searchkick | @@ -41,12 +41,19 @@ module Searchkick | ||
41 | 41 | ||
42 | # sort | 42 | # sort |
43 | hits.map do |hit| | 43 | hits.map do |hit| |
44 | - result = results[hit["_type"]].find{|r| r.id.to_s == hit["_id"].to_s } | ||
45 | - result.response_search_data = build_hashie_result hit if options[:include_search_data] and result | ||
46 | - result | 44 | + results[hit["_type"]].find{|r| r.id.to_s == hit["_id"].to_s } |
47 | end.compact | 45 | end.compact |
48 | else | 46 | else |
49 | - hits.map { |hit| build_hashie_result hit } | 47 | + hits.map do |hit| |
48 | + result = | ||
49 | + if hit["_source"] | ||
50 | + hit.except("_source").merge(hit["_source"]) | ||
51 | + else | ||
52 | + hit.except("fields").merge(hit["fields"]) | ||
53 | + end | ||
54 | + result["id"] ||= result["_id"] # needed for legacy reasons | ||
55 | + Hashie::Mash.new(result) | ||
56 | + end | ||
50 | end | 57 | end |
51 | end | 58 | end |
52 | end | 59 | end |
@@ -136,16 +143,5 @@ module Searchkick | @@ -136,16 +143,5 @@ module Searchkick | ||
136 | @response["hits"]["hits"] | 143 | @response["hits"]["hits"] |
137 | end | 144 | end |
138 | 145 | ||
139 | - def build_hashie_result hit | ||
140 | - result = | ||
141 | - if hit["_source"] | ||
142 | - hit.except("_source").merge(hit["_source"]) | ||
143 | - else | ||
144 | - hit.except("fields").merge(hit["fields"]) | ||
145 | - end | ||
146 | - result["id"] ||= result["_id"] # needed for legacy reasons | ||
147 | - Hashie::Mash.new(result) | ||
148 | - end | ||
149 | - | ||
150 | end | 146 | end |
151 | end | 147 | end |