Class: Sunspot::Query::FieldStats
- Inherits:
-
Object
- Object
- Sunspot::Query::FieldStats
- Defined in:
- lib/sunspot/query/field_stats.rb
Instance Method Summary collapse
- #add_facet(field) ⇒ Object
- #facet_key ⇒ Object
-
#initialize(field, options) ⇒ FieldStats
constructor
A new instance of FieldStats.
- #qualified_param(name) ⇒ Object
- #to_params ⇒ Object
Constructor Details
#initialize(field, options) ⇒ FieldStats
Returns a new instance of FieldStats.
4 5 6 7 |
# File 'lib/sunspot/query/field_stats.rb', line 4 def initialize(field, ) @field, @options = field, @facets = [] end |
Instance Method Details
#add_facet(field) ⇒ Object
9 10 11 |
# File 'lib/sunspot/query/field_stats.rb', line 9 def add_facet field @facets << field end |
#facet_key ⇒ Object
19 20 21 |
# File 'lib/sunspot/query/field_stats.rb', line 19 def facet_key qualified_param 'facet' end |
#qualified_param(name) ⇒ Object
23 24 25 |
# File 'lib/sunspot/query/field_stats.rb', line 23 def qualified_param name :"f.#{@field.indexed_name}.stats.#{name}" end |
#to_params ⇒ Object
13 14 15 16 17 |
# File 'lib/sunspot/query/field_stats.rb', line 13 def to_params params = { :stats => true, :"stats.field" => [@field.indexed_name]} params[facet_key] = @facets.map(&:indexed_name) unless @facets.empty? params end |