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 | 7 | class_eval do |
8 | 8 | cattr_reader :searchkick_options, :searchkick_env, :searchkick_klass |
9 | 9 | |
10 | - attr_accessor :response_search_data | |
11 | - | |
12 | 10 | callbacks = options.has_key?(:callbacks) ? options[:callbacks] : true |
13 | 11 | |
14 | 12 | class_variable_set :@@searchkick_options, options.dup | ... | ... |
lib/searchkick/query.rb
... | ... | @@ -328,7 +328,7 @@ module Searchkick |
328 | 328 | |
329 | 329 | # An empty array will cause only the _id and _type for each hit to be returned |
330 | 330 | # http://www.elasticsearch.org/guide/reference/api/search/fields/ |
331 | - if load and not options[:include_search_data] | |
331 | + if load | |
332 | 332 | payload[:fields] = [] |
333 | 333 | elsif options[:select] |
334 | 334 | payload[:fields] = options[:select] |
... | ... | @@ -408,7 +408,6 @@ module Searchkick |
408 | 408 | per_page: @per_page, |
409 | 409 | padding: @padding, |
410 | 410 | load: @load, |
411 | - include_search_data: options[:include_search_data] || false, | |
412 | 411 | includes: options[:include] || options[:includes], |
413 | 412 | json: !options[:json].nil? |
414 | 413 | } | ... | ... |
lib/searchkick/results.rb
... | ... | @@ -41,12 +41,19 @@ module Searchkick |
41 | 41 | |
42 | 42 | # sort |
43 | 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 | 45 | end.compact |
48 | 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 | 57 | end |
51 | 58 | end |
52 | 59 | end |
... | ... | @@ -136,16 +143,5 @@ module Searchkick |
136 | 143 | @response["hits"]["hits"] |
137 | 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 | 146 | end |
151 | 147 | end | ... | ... |