Class: Sunspot::Query::RangeFacet

Inherits:
AbstractFieldFacet show all
Defined in:
lib/sunspot/query/range_facet.rb

Instance Method Summary collapse

Constructor Details

#initialize(field, options) ⇒ RangeFacet

Returns a new instance of RangeFacet.



5
6
7
8
9
10
11
12
# File 'lib/sunspot/query/range_facet.rb', line 5

def initialize(field, options)
  if exclude_filters = options[:exclude]
    @exclude_tag = Util.Array(exclude_filters).map do |filter|
      filter.tag
    end.join(',')
  end
  super
end

Instance Method Details

#to_paramsObject



14
15
16
17
18
19
20
21
22
# File 'lib/sunspot/query/range_facet.rb', line 14

def to_params
  params = super
  params[:"facet.range"] = [field_name_with_local_params]
  params[qualified_param('range.start')] = @field.to_indexed(@options[:range].first)
  params[qualified_param('range.end')] = @field.to_indexed(@options[:range].last)
  params[qualified_param('range.gap')] = "#{@options[:range_interval] || 10}"
  params[qualified_param('range.include')] = @options[:include].to_s if @options[:include]
  params
end