Class: Solr::Query::Response
- Inherits:
-
Object
- Object
- Solr::Query::Response
- Defined in:
- lib/solr/query/response.rb,
lib/solr/query/response/parser.rb,
lib/solr/query/response/spellcheck.rb,
lib/solr/query/response/facet_value.rb,
lib/solr/query/response/field_facets.rb
Defined Under Namespace
Classes: FacetValue, FieldFacets, Parser, Spellcheck
Instance Attribute Summary collapse
-
#available_facets ⇒ Object
readonly
Returns the value of attribute available_facets.
-
#documents ⇒ Object
readonly
Returns the value of attribute documents.
-
#spellcheck ⇒ Object
readonly
Returns the value of attribute spellcheck.
Class Method Summary collapse
Instance Method Summary collapse
- #empty? ⇒ Boolean
-
#initialize(documents:, available_facets: [], spellcheck: Solr::Query::Response::Spellcheck.empty) ⇒ Response
constructor
A new instance of Response.
- #total_count ⇒ Object
Constructor Details
#initialize(documents:, available_facets: [], spellcheck: Solr::Query::Response::Spellcheck.empty) ⇒ Response
Returns a new instance of Response.
33 34 35 36 37 |
# File 'lib/solr/query/response.rb', line 33 def initialize(documents:, available_facets: [], spellcheck: Solr::Query::Response::Spellcheck.empty) @documents = documents @available_facets = available_facets @spellcheck = spellcheck end |
Instance Attribute Details
#available_facets ⇒ Object (readonly)
Returns the value of attribute available_facets.
9 10 11 |
# File 'lib/solr/query/response.rb', line 9 def available_facets @available_facets end |
#documents ⇒ Object (readonly)
Returns the value of attribute documents.
9 10 11 |
# File 'lib/solr/query/response.rb', line 9 def documents @documents end |
#spellcheck ⇒ Object (readonly)
Returns the value of attribute spellcheck.
9 10 11 |
# File 'lib/solr/query/response.rb', line 9 def spellcheck @spellcheck end |
Class Method Details
.empty ⇒ Object
12 13 14 |
# File 'lib/solr/query/response.rb', line 12 def empty new(documents: Solr::DocumentCollection.empty) end |
.empty_grouped ⇒ Object
16 17 18 |
# File 'lib/solr/query/response.rb', line 16 def empty_grouped new(documents: Solr::GroupedDocumentCollection.empty) end |
.manual_grouped_documents(ids) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/solr/query/response.rb', line 20 def manual_grouped_documents(ids) documents = ids.map { |id| Solr::Document.new(id: id) } group_counts = ids.each_with_object({}) do |id, acc| acc[id] = 1 end new(documents: Solr::GroupedDocumentCollection.new( documents: documents, total_count: ids.count, group_counts: group_counts )) end |
Instance Method Details
#empty? ⇒ Boolean
43 44 45 |
# File 'lib/solr/query/response.rb', line 43 def empty? total_count.zero? end |
#total_count ⇒ Object
39 40 41 |
# File 'lib/solr/query/response.rb', line 39 def total_count @documents.total_count end |