Class: Sunspot::Query::AbstractFieldFacet
- Inherits:
-
Object
- Object
- Sunspot::Query::AbstractFieldFacet
show all
- Includes:
- RSolr::Char
- Defined in:
- lib/sunspot/query/abstract_field_facet.rb
Instance Method Summary
collapse
Constructor Details
6
7
8
|
# File 'lib/sunspot/query/abstract_field_facet.rb', line 6
def initialize(field, options)
@field, @options = field, options
end
|
Instance Method Details
#to_params ⇒ Object
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
# File 'lib/sunspot/query/abstract_field_facet.rb', line 10
def to_params
params = {
:facet => 'true',
}
case @options[:sort]
when :count
params[qualified_param('sort')] = 'true'
when :index
params[qualified_param('sort')] = 'false'
when nil
else
raise(
ArgumentError,
"#{@options[:sort].inspect} is not an allowed value for :sort. Allowed options are :count and :index"
)
end
if @options[:limit]
params[qualified_param('limit')] = @options[:limit].to_i
end
if @options[:prefix]
params[qualified_param('prefix')] = escape(@options[:prefix].to_s)
end
params[qualified_param('mincount')] =
case
when @options[:minimum_count] then @options[:minimum_count].to_i
when @options[:zeros] then 0
else 1
end
params
end
|