Class: Solr::Response::Standard
- Includes:
- Enumerable
- Defined in:
- lib/solr/response/standard.rb
Overview
The ASF licenses this file to You under the Apache License, Version 2.0 (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Direct Known Subclasses
Defined Under Namespace
Classes: FacetValue
Instance Attribute Summary
Attributes inherited from Ruby
Attributes inherited from Base
Instance Method Summary collapse
-
#each ⇒ Object
supports enumeration of hits TODO revisit - should this iterate through all hits by re-requesting more?.
-
#field_facets(field) ⇒ Object
TODO: consider the use of json.nl parameter.
- #highlighted(id, field) ⇒ Object
- #hits ⇒ Object
-
#initialize(ruby_code) ⇒ Standard
constructor
A new instance of Standard.
- #max_score ⇒ Object
- #start ⇒ Object
- #total_hits ⇒ Object
Methods inherited from Ruby
Methods inherited from Base
Constructor Details
#initialize(ruby_code) ⇒ Standard
Returns a new instance of Standard.
17 18 19 20 21 |
# File 'lib/solr/response/standard.rb', line 17 def initialize(ruby_code) super @response = @data['response'] raise "response section missing" unless @response.kind_of? Hash end |
Instance Method Details
#each ⇒ Object
supports enumeration of hits TODO revisit - should this iterate through all hits by re-requesting more?
56 57 58 |
# File 'lib/solr/response/standard.rb', line 56 def each @response['docs'].each {|hit| yield hit} end |
#field_facets(field) ⇒ Object
TODO: consider the use of json.nl parameter
40 41 42 43 44 45 46 47 48 |
# File 'lib/solr/response/standard.rb', line 40 def field_facets(field) facets = [] values = @data['facet_counts']['facet_fields'][field] Solr::Util.paired_array_each(values) do |key, value| facets << FacetValue.new(key, value) end facets end |
#highlighted(id, field) ⇒ Object
50 51 52 |
# File 'lib/solr/response/standard.rb', line 50 def highlighted(id, field) @data['highlighting'][id.to_s][field.to_s] rescue nil end |
#hits ⇒ Object
31 32 33 |
# File 'lib/solr/response/standard.rb', line 31 def hits @response['docs'] end |
#max_score ⇒ Object
35 36 37 |
# File 'lib/solr/response/standard.rb', line 35 def max_score @response['maxScore'] end |
#start ⇒ Object
27 28 29 |
# File 'lib/solr/response/standard.rb', line 27 def start @response['start'] end |
#total_hits ⇒ Object
23 24 25 |
# File 'lib/solr/response/standard.rb', line 23 def total_hits @response['numFound'] end |