Class: Solr::Query::Response::Parser

Inherits:
Object
  • Object
show all
Includes:
Support::SchemaHelper
Defined in:
lib/solr/query/response/parser.rb

Constant Summary collapse

SOLR_INFINITY =

for cases like [100000 TO *]

'*'.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Support::SchemaHelper

#solarize_field

Constructor Details

#initialize(request:, solr_response:) ⇒ Parser

Returns a new instance of Parser.



11
12
13
14
# File 'lib/solr/query/response/parser.rb', line 11

def initialize(request:, solr_response:)
  @request = request
  @solr_response = solr_response
end

Instance Attribute Details

#requestObject (readonly)

Returns the value of attribute request.



9
10
11
# File 'lib/solr/query/response/parser.rb', line 9

def request
  @request
end

#solr_responseObject (readonly)

Returns the value of attribute solr_response.



9
10
11
# File 'lib/solr/query/response/parser.rb', line 9

def solr_response
  @solr_response
end

Instance Method Details

#to_responseObject



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/solr/query/response/parser.rb', line 16

def to_response
  documents = parse_documents
  total_count = parse_total_count
  if !request.grouping.empty?
    group_counts = parse_group_counts
    document_collection = Solr::GroupedDocumentCollection.new(documents: documents,
                                                              total_count: total_count,
                                                              group_counts: group_counts)
  else
    document_collection = Solr::DocumentCollection.new(documents: documents, total_count: total_count)
  end
  Solr::Query::Response.new(
    documents: document_collection,
    available_facets: field_facet_collection,
    spellcheck: spellcheck
  )
end