Commit 4c23cb6b30e87e5a2efcfbdbcc5c0d685ed85077

Authored by Andrew Kane
1 parent 1f45e928

Code cleaning

Showing 1 changed file with 3 additions and 5 deletions   Show diff stats
lib/searchkick/index.rb
... ... @@ -44,7 +44,7 @@ module Searchkick
44 44 client.bulk(
45 45 index: name,
46 46 type: type,
47   - body: batch.map{|r| data = search_data(r); {index: {_id: search_id(r), data: data}} }
  47 + body: batch.map{|r| {index: {_id: search_id(r), data: search_data(r)}} }
48 48 )
49 49 end
50 50 end
... ... @@ -81,13 +81,13 @@ module Searchkick
81 81  
82 82 def search_data(record)
83 83 source = record.search_data
  84 + options = record.class.searchkick_options
84 85  
85 86 # stringify fields
  87 + # remove _id since search_id is used instead
86 88 source = source.inject({}){|memo,(k,v)| memo[k.to_s] = v; memo}.except("_id")
87 89 source["id"] ||= search_id(record)
88 90  
89   - options = record.class.searchkick_options
90   -
91 91 # conversions
92 92 conversions_field = options[:conversions]
93 93 if conversions_field and source[conversions_field]
... ... @@ -112,8 +112,6 @@ module Searchkick
112 112  
113 113 cast_big_decimal(source)
114 114  
115   - # p search_data
116   -
117 115 source.as_json
118 116 end
119 117  
... ...