Class: SirvRestApi::SearchResult
- Inherits:
-
Object
- Object
- SirvRestApi::SearchResult
- Defined in:
- lib/sirv_rest_api/models.rb
Overview
Search result
Instance Attribute Summary collapse
-
#hits ⇒ Object
Returns the value of attribute hits.
-
#scroll_id ⇒ Object
Returns the value of attribute scroll_id.
-
#total ⇒ Object
Returns the value of attribute total.
Instance Method Summary collapse
-
#initialize(data = {}) ⇒ SearchResult
constructor
A new instance of SearchResult.
Constructor Details
#initialize(data = {}) ⇒ SearchResult
Returns a new instance of SearchResult.
216 217 218 219 220 221 222 223 224 225 226 227 |
# File 'lib/sirv_rest_api/models.rb', line 216 def initialize(data = {}) raw_hits = data["hits"] || [] @hits = raw_hits.map do |hit| # Handle Elasticsearch _source format source = hit["_source"] || hit FileInfo.new(source) end # Handle Elasticsearch total format total_data = data["total"] @total = total_data.is_a?(Hash) ? total_data["value"] : total_data @scroll_id = data["scrollId"] end |
Instance Attribute Details
#hits ⇒ Object
Returns the value of attribute hits.
214 215 216 |
# File 'lib/sirv_rest_api/models.rb', line 214 def hits @hits end |
#scroll_id ⇒ Object
Returns the value of attribute scroll_id.
214 215 216 |
# File 'lib/sirv_rest_api/models.rb', line 214 def scroll_id @scroll_id end |
#total ⇒ Object
Returns the value of attribute total.
214 215 216 |
# File 'lib/sirv_rest_api/models.rb', line 214 def total @total end |