vendor/plugins/acts_as_solr/lib/parser_methods.rb
# Parses the data returned from Solr
Parses the data returned from Solr
Parses the data returned from Solr
def parse_results(solr_data, options = {})
      results = {
        :docs => [],
        :total => 0
      }
      configuration = {
        :format => :objects
      }
      results.update(:facets => {'facet_fields' => []}) if options[:facets]
      return SearchResults.new(results) if solr_data.total == 0
      configuration.update(options) if options.is_a?(Hash)
      ids = solr_data.docs.collect {|doc| doc["#{solr_configuration[:primary_key_field]}"]}.flatten
      conditions = [ "#{self.table_name}.#{primary_key} in (?)", ids ]
      find_options = {:conditions => conditions}
      find_options[:include] = options[:include] if options[:include]
      result = configuration[:format] == :objects ? reorder(self.find(:all, find_options), ids) : ids
      add_scores(result, solr_data) if configuration[:format] == :objects && options[:scores]
      results.update(:facets => solr_data.data['facet_counts']) if options[:facets]
      results.update({:docs => result, :total => solr_data.total, :max_score => solr_data.max_score, :query_time => solr_data.data['responseHeader']['QTime']})
      SearchResults.new(results)
    end
def parse_results ( solr_data , options = { } ) results = { :docs => [ ] , :total => 0 } configuration = { :format => :objects } results . update ( :facets => { 'facet_fields' => [ ] } ) if options [ :facets ] return SearchResults . new ( results ) if solr_data . total == 0 configuration . update ( options ) if options . is_a? ( Hash ) ids = solr_data . docs . collect { | doc | doc [ "#{solr_configuration[:primary_key_field]}" ] } . flatten conditions = [ "#{self.table_name}.#{primary_key} in (?)" , ids ] find_options = { :conditions => conditions } find_options [ :include ] = options [ :include ] if options [ :include ] result = configuration [ :format ] == :objects ? reorder ( self . find ( :all , find_options ) , ids ) : ids add_scores ( result , solr_data ) if configuration [ :format ] == :objects && options [ :scores ] results . update ( :facets => solr_data . data [ 'facet_counts' ] ) if options [ :facets ] results . update ( { :docs => result , :total => solr_data . total , :max_score => solr_data . max_score , :query_time => solr_data . data [ 'responseHeader' ] [ 'QTime' ] } ) SearchResults . new ( results ) end
Parses the data returned from Solr
Parses the data returned from Solr
solr_data
<not_specific>
options
<not_specific>