Class: Stellr::Search::SearchResult
- Inherits:
-
Object
- Object
- Stellr::Search::SearchResult
- Defined in:
- lib/stellr/search/search_result.rb
Overview
A single search result
Instance Attribute Summary collapse
-
#doc_id ⇒ Object
readonly
Returns the value of attribute doc_id.
-
#score ⇒ Object
readonly
Returns the value of attribute score.
Instance Method Summary collapse
-
#field(name) ⇒ Object
(also: #[])
retrieve contents of the field
name
. -
#initialize(id, score, field_data) ⇒ SearchResult
constructor
A new instance of SearchResult.
- #to_json ⇒ Object
Constructor Details
#initialize(id, score, field_data) ⇒ SearchResult
Returns a new instance of SearchResult.
8 9 10 11 12 |
# File 'lib/stellr/search/search_result.rb', line 8 def initialize(id, score, field_data) @doc_id = id @score = score @field_data = field_data end |
Instance Attribute Details
#doc_id ⇒ Object (readonly)
Returns the value of attribute doc_id.
6 7 8 |
# File 'lib/stellr/search/search_result.rb', line 6 def doc_id @doc_id end |
#score ⇒ Object (readonly)
Returns the value of attribute score.
6 7 8 |
# File 'lib/stellr/search/search_result.rb', line 6 def score @score end |
Instance Method Details
#field(name) ⇒ Object Also known as: []
retrieve contents of the field name
15 16 17 |
# File 'lib/stellr/search/search_result.rb', line 15 def field(name) @field_data[name] end |
#to_json ⇒ Object
20 21 22 23 24 25 26 |
# File 'lib/stellr/search/search_result.rb', line 20 def to_json { :doc_id => @doc_id, :score => @score, :data => @field_data }.to_json end |