Module: ElasticRecord::Relation::Hits
- Included in:
- ElasticRecord::Relation
- Defined in:
- lib/elastic_record/relation/hits.rb
Instance Method Summary collapse
- #load_hits(search_hits) ⇒ Object
- #map_hits_to_ids(hits) ⇒ Object
- #search_hits ⇒ Object
- #search_results ⇒ Object
- #to_ids ⇒ Object
Instance Method Details
#load_hits(search_hits) ⇒ Object
8 9 10 11 12 13 14 |
# File 'lib/elastic_record/relation/hits.rb', line 8 def load_hits(search_hits) if klass.elastic_index.load_from_source search_hits.map { |hit| klass.new(hit['_source'].update('id' => hit['_id'])) } else klass.find map_hits_to_ids(search_hits) end end |
#map_hits_to_ids(hits) ⇒ Object
16 17 18 |
# File 'lib/elastic_record/relation/hits.rb', line 16 def map_hits_to_ids(hits) hits.map { |hit| hit['_id'] } end |
#search_hits ⇒ Object
20 21 22 |
# File 'lib/elastic_record/relation/hits.rb', line 20 def search_hits search_results['hits']['hits'] end |
#search_results ⇒ Object
24 25 26 27 28 29 30 31 |
# File 'lib/elastic_record/relation/hits.rb', line 24 def search_results @search_results ||= begin = {typed_keys: true} [:search_type] = search_type_value if search_type_value klass.elastic_index.search(as_elastic, ) end end |
#to_ids ⇒ Object
4 5 6 |
# File 'lib/elastic_record/relation/hits.rb', line 4 def to_ids map_hits_to_ids search_hits end |