Class: SolrLite::Highlights

Inherits:
Object
  • Object
show all
Defined in:
lib/highlights.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(solr_reponse_hash) ⇒ Highlights

solr_response_hash a Solr HTTP response parsed via JSON.parse()



5
6
7
# File 'lib/highlights.rb', line 5

def initialize(solr_reponse_hash)
  @highlighting = solr_reponse_hash.fetch("highlighting", {})
end

Class Method Details

.from_response(solr_response) ⇒ Object

solr_response (string) is the Solr HTTP response from a query



10
11
12
13
# File 'lib/highlights.rb', line 10

def self.from_response(solr_response)
  hash = JSON.parse(solr_response)
  Highlights.new(hash)
end

Instance Method Details

#for(id) ⇒ Object

Returns the highlight information for the given document ID.



16
17
18
19
# File 'lib/highlights.rb', line 16

def for(id)
  return nil if @highlighting[id] == nil
  @highlighting[id]
end