Class: ActsAsSolr::SearchResults
- Inherits:
-
Object
- Object
- ActsAsSolr::SearchResults
- Defined in:
- lib/search_results.rb
Overview
TODO: Possibly looking into hooking it up with Solr::Response::Standard
Class that returns the search results with four methods.
books = Book.find_by_solr 'ruby'
the above will return a SearchResults class with 4 methods:
docs|results|records: will return an array of records found
books.records.empty?
=> false
total|num_found|total_hits: will return the total number of records found
books.total
=> 2
facets: will return the facets when doing a faceted search
max_score|highest_score: returns the highest score found
books.max_score
=> 1.3213213
Instance Method Summary collapse
-
#facets ⇒ Object
Returns the facets when doing a faceted search.
-
#initialize(solr_data = {}) ⇒ SearchResults
constructor
A new instance of SearchResults.
-
#max_score ⇒ Object
(also: #highest_score)
Returns the highest score found.
- #query_time ⇒ Object
-
#results ⇒ Object
(also: #docs, #records)
Returns an array with the instances.
-
#total ⇒ Object
(also: #num_found, #total_hits)
Returns the total records found.
Constructor Details
#initialize(solr_data = {}) ⇒ SearchResults
Returns a new instance of SearchResults.
30 31 32 33 |
# File 'lib/search_results.rb', line 30 def initialize(solr_data={}) @solr_data = solr_data # $log.debug "sd:#{solr_data.inspect}" end |
Instance Method Details
#facets ⇒ Object
Returns the facets when doing a faceted search
48 49 50 |
# File 'lib/search_results.rb', line 48 def facets @solr_data[:facets] end |
#max_score ⇒ Object Also known as: highest_score
Returns the highest score found. This method is also aliased as highest_score
54 55 56 |
# File 'lib/search_results.rb', line 54 def max_score @solr_data[:max_score] end |
#query_time ⇒ Object
58 59 60 |
# File 'lib/search_results.rb', line 58 def query_time @solr_data[:query_time] end |
#results ⇒ Object Also known as: docs, records
Returns an array with the instances. This method is also aliased as docs and records
37 38 39 |
# File 'lib/search_results.rb', line 37 def results @solr_data[:docs] end |
#total ⇒ Object Also known as: num_found, total_hits
Returns the total records found. This method is also aliased as num_found and total_hits
43 44 45 |
# File 'lib/search_results.rb', line 43 def total @solr_data[:total] end |