Class: SimpleSolrClient::Response::Document
- Inherits:
-
Object
- Object
- SimpleSolrClient::Response::Document
- Extended by:
- Forwardable
- Includes:
- Comparable
- Defined in:
- lib/simple_solr_client/response/document.rb
Instance Attribute Summary collapse
-
#rank ⇒ Object
!@attribute solr_doc_hash @return [Hash] the original, un-munged solr data for this document passed into the initializer.
-
#solr_doc_hash ⇒ Object
!@attribute solr_doc_hash @return [Hash] the original, un-munged solr data for this document passed into the initializer.
Instance Method Summary collapse
- #<=>(other) ⇒ Object
-
#[](key) ⇒ String+
The value(s) of the requested field.
-
#id ⇒ Object
The value of the ‘id’ field of this document.
-
#initialize(solrdochash) ⇒ Document
constructor
Create a single document from a Hash representation of the solr return value as returned by a solr query.
-
#score ⇒ Object
The score of this document on thsi query.
- #to_h ⇒ Object
Constructor Details
#initialize(solrdochash) ⇒ Document
Create a single document from a Hash representation of the solr return value as returned by a solr query
25 26 27 |
# File 'lib/simple_solr_client/response/document.rb', line 25 def initialize(solrdochash) @solr_doc_hash = solrdochash end |
Instance Attribute Details
#rank ⇒ Object
!@attribute solr_doc_hash
@return [Hash] the original, un-munged solr data for this document passed into the initializer
19 20 21 |
# File 'lib/simple_solr_client/response/document.rb', line 19 def rank @rank end |
#solr_doc_hash ⇒ Object
!@attribute solr_doc_hash
@return [Hash] the original, un-munged solr data for this document passed into the initializer
19 20 21 |
# File 'lib/simple_solr_client/response/document.rb', line 19 def solr_doc_hash @solr_doc_hash end |
Instance Method Details
#<=>(other) ⇒ Object
7 8 9 10 |
# File 'lib/simple_solr_client/response/document.rb', line 7 def <=>(other) other = other.score if other.respond_to? :score, self.score <=> other end |
#[](key) ⇒ String+
Returns the value(s) of the requested field.
15 |
# File 'lib/simple_solr_client/response/document.rb', line 15 def_delegators :@solr_doc_hash, :[], :keys, :values, :to_s |
#id ⇒ Object
The value of the ‘id’ field of this document
31 32 33 |
# File 'lib/simple_solr_client/response/document.rb', line 31 def id @solr_doc_hash['id'] end |
#score ⇒ Object
The score of this document on thsi query
36 37 38 |
# File 'lib/simple_solr_client/response/document.rb', line 36 def score @solr_doc_hash['score'] end |
#to_h ⇒ Object
41 42 43 |
# File 'lib/simple_solr_client/response/document.rb', line 41 def to_h @solr_doc_hash.merge({'_rank' => @rank}) end |