Commit 23e4261f89589a3960549af2a9c550d2edc61339

Authored by Andrew Kane
1 parent 5b61b7d1

Updated select option

lib/searchkick/query.rb
... ... @@ -292,7 +292,11 @@ module Searchkick
292 292  
293 293 # An empty array will cause only the _id and _type for each hit to be returned
294 294 # http://www.elasticsearch.org/guide/reference/api/search/fields/
295   - payload[:fields] = [] if load
  295 + if load
  296 + payload[:fields] = []
  297 + elsif options[:select]
  298 + payload[:fields] = options[:select]
  299 + end
296 300  
297 301 if options[:type] or klass != searchkick_klass
298 302 @type = [options[:type] || klass].flatten.map{|v| searchkick_index.klass_document_type(v) }
... ...
lib/searchkick/results.rb
... ... @@ -42,7 +42,7 @@ module Searchkick
42 42 if hit["_source"]
43 43 hit.except("_source").merge(hit["_source"])
44 44 else
45   - hit.except("fields").merge(Hash[ hit["fields"].map{|k, v| [k, v.first] } ])
  45 + hit.except("fields").merge(hit["fields"])
46 46 end
47 47 result["id"] ||= result["_id"] # needed for legacy reasons
48 48 Hashie::Mash.new(result)
... ...