Class: Sunspot::Query::FieldStat
- Inherits:
-
Object
- Object
- Sunspot::Query::FieldStat
- Defined in:
- lib/query/field_stat.rb
Overview
A FieldStat stats by the unique values of a given field.
Instance Method Summary collapse
- #add_sort(sort) ⇒ Object
-
#initialize(field, options = {}) ⇒ FieldStat
constructor
A new instance of FieldStat.
- #to_params ⇒ Object
Constructor Details
#initialize(field, options = {}) ⇒ FieldStat
Returns a new instance of FieldStat.
8 9 10 11 12 13 14 15 |
# File 'lib/query/field_stat.rb', line 8 def initialize(field, = {}) if field.multiple? raise(ArgumentError, "#{field.name} cannot be used for stats because it is a multiple-value field") end @field = field @options = @sort = SortComposite.new end |
Instance Method Details
#add_sort(sort) ⇒ Object
17 18 19 |
# File 'lib/query/field_stat.rb', line 17 def add_sort(sort) @sort << sort end |
#to_params ⇒ Object
21 22 23 24 25 26 27 28 |
# File 'lib/query/field_stat.rb', line 21 def to_params params = { :stats => 'true', :"stats.field" => @field.indexed_name } params.merge!({:"stats.facet" => @options[:facet].indexed_name}) if !@options[:facet].nil? params end |