Class: Elastics::ActiveRecord::SearchResult
- Inherits:
-
Result::Search
- Object
- Result::Search
- Elastics::ActiveRecord::SearchResult
- Defined in:
- lib/elastics/active_record/search_result.rb
Instance Attribute Summary
Attributes inherited from Result::Search
Instance Method Summary collapse
- #collection ⇒ Object
-
#ids ⇒ Object
super.map(&:to_i).
-
#initialize(response, options = {}) ⇒ SearchResult
constructor
A new instance of SearchResult.
- #relation ⇒ Object
Methods inherited from Result::Search
#aggregations, #hits, #ids_to_find, #rest_ids, #total
Constructor Details
#initialize(response, options = {}) ⇒ SearchResult
4 5 6 7 |
# File 'lib/elastics/active_record/search_result.rb', line 4 def initialize(response, = {}) @model = [:model] super response, end |
Instance Method Details
#collection ⇒ Object
14 15 16 |
# File 'lib/elastics/active_record/search_result.rb', line 14 def collection @collection ||= @model.find_all_ordered ids_to_find end |
#ids ⇒ Object
super.map(&:to_i)
10 11 12 |
# File 'lib/elastics/active_record/search_result.rb', line 10 def ids @ids ||= hits['hits'.freeze].map { |x| x['_id'.freeze].to_i } end |
#relation ⇒ Object
18 19 20 |
# File 'lib/elastics/active_record/search_result.rb', line 18 def relation @model.where(id: ids_to_find) end |