Class: ElasticRecord::SearchHits
- Inherits:
-
Object
- Object
- ElasticRecord::SearchHits
- Defined in:
- lib/elastic_record/search_hits.rb
Instance Attribute Summary collapse
-
#hits ⇒ Object
Returns the value of attribute hits.
-
#model ⇒ Object
Returns the value of attribute model.
-
#total ⇒ Object
Returns the value of attribute total.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(hits, total: nil) ⇒ SearchHits
constructor
A new instance of SearchHits.
- #to_ids ⇒ Object
Constructor Details
#initialize(hits, total: nil) ⇒ SearchHits
Returns a new instance of SearchHits.
11 12 13 14 |
# File 'lib/elastic_record/search_hits.rb', line 11 def initialize(hits, total: nil) @hits = hits @total = total.is_a?(Hash) ? total['value'] : total end |
Instance Attribute Details
#hits ⇒ Object
Returns the value of attribute hits.
3 4 5 |
# File 'lib/elastic_record/search_hits.rb', line 3 def hits @hits end |
#model ⇒ Object
Returns the value of attribute model.
3 4 5 |
# File 'lib/elastic_record/search_hits.rb', line 3 def model @model end |
#total ⇒ Object
Returns the value of attribute total.
3 4 5 |
# File 'lib/elastic_record/search_hits.rb', line 3 def total @total end |
Class Method Details
.from_response(response) ⇒ Object
6 7 8 |
# File 'lib/elastic_record/search_hits.rb', line 6 def from_response(response) new(response['hits']['hits'], total: response['hits']['total']) end |
Instance Method Details
#to_ids ⇒ Object
16 17 18 |
# File 'lib/elastic_record/search_hits.rb', line 16 def to_ids hits.map { |hit| hit['_id'] } end |