Class ActsAsSolr::SearchResults
In: lib/search_results.rb
Parent: Object

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

Methods

docs   facets   highest_score   max_score   new   num_found   records   results   total   total_hits  

Public Class methods

[Source]

# File lib/search_results.rb, line 30
    def initialize(solr_data={})
      @solr_data = solr_data
    end

Public Instance methods

docs()

Alias for results

Returns the facets when doing a faceted search

[Source]

# File lib/search_results.rb, line 47
    def facets
      @solr_data[:facets]
    end
highest_score()

Alias for max_score

Returns the highest score found. This method is also aliased as highest_score

[Source]

# File lib/search_results.rb, line 53
    def max_score
      @solr_data[:max_score]
    end
num_found()

Alias for total

records()

Alias for results

Returns an array with the instances. This method is also aliased as docs and records

[Source]

# File lib/search_results.rb, line 36
    def results
      @solr_data[:docs]
    end

Returns the total records found. This method is also aliased as num_found and total_hits

[Source]

# File lib/search_results.rb, line 42
    def total
      @solr_data[:total]
    end
total_hits()

Alias for total

[Validate]