Module: RSolr::Ext::Response::Facets
- Defined in:
- lib/rsolr-ext/response/facets.rb
Defined Under Namespace
Classes: FacetField, FacetItem
Instance Method Summary collapse
-
#facet_by_field_name(name) ⇒ Object
pass in a facet field name and get back a Facet instance.
- #facet_counts ⇒ Object
-
#facet_fields ⇒ Object
Returns the hash of all the facet_fields (ie: => [‘true’, 123, ‘false’, 20].
-
#facet_queries ⇒ Object
Returns all of the facet queries.
-
#facets ⇒ Object
end “caches” the result in the @facets instance var.
Instance Method Details
#facet_by_field_name(name) ⇒ Object
pass in a facet field name and get back a Facet instance
37 38 39 40 41 42 |
# File 'lib/rsolr-ext/response/facets.rb', line 37 def facet_by_field_name(name) @facets_by_field_name ||= {} @facets_by_field_name[name] ||= ( facets.detect{|facet|facet.name.to_s == name.to_s} ) end |
#facet_counts ⇒ Object
44 45 46 |
# File 'lib/rsolr-ext/response/facets.rb', line 44 def facet_counts @facet_counts ||= self['facet_counts'] || {} end |
#facet_fields ⇒ Object
Returns the hash of all the facet_fields (ie: => [‘true’, 123, ‘false’, 20]
49 50 51 |
# File 'lib/rsolr-ext/response/facets.rb', line 49 def facet_fields @facet_fields ||= facet_counts['facet_fields'] || {} end |
#facet_queries ⇒ Object
Returns all of the facet queries
54 55 56 |
# File 'lib/rsolr-ext/response/facets.rb', line 54 def facet_queries @facet_queries ||= facet_counts['facet_queries'] || {} end |
#facets ⇒ Object
end “caches” the result in the @facets instance var
24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/rsolr-ext/response/facets.rb', line 24 def facets @facets ||= ( facet_fields.map do |(facet_field_name,values_and_hits)| items = [] values_and_hits.each_slice(2) do |k,v| items << FacetItem.new(k, v) end FacetField.new(facet_field_name, items) end ) end |