Module: Chewy::Index::Wrapper::ClassMethods

Defined in:
lib/chewy/index/wrapper.rb

Instance Method Summary collapse

Instance Method Details

#build(hit) ⇒ Object



12
13
14
15
16
17
18
19
20
21
# File 'lib/chewy/index/wrapper.rb', line 12

def build(hit)
  attributes = (hit['_source'] || {})
    .reverse_merge(id: hit['_id'])
    .merge!(_score: hit['_score'])
    .merge!(_explanation: hit['_explanation'])

  wrapper = new(attributes)
  wrapper._data = hit
  wrapper
end