Class: Sunspot::Query::RangeJsonFacet
- Inherits:
-
AbstractJsonFieldFacet
- Object
- AbstractJsonFieldFacet
- Sunspot::Query::RangeJsonFacet
- Defined in:
- lib/sunspot/query/range_json_facet.rb
Direct Known Subclasses
Constant Summary collapse
- SECONDS_IN_DAY =
86400
Constants inherited from AbstractJsonFieldFacet
AbstractJsonFieldFacet::DISTINCT_STRATEGIES
Instance Attribute Summary
Attributes inherited from AbstractJsonFieldFacet
Instance Method Summary collapse
- #field_name_with_local_params ⇒ Object
-
#initialize(field, options, setup) ⇒ RangeJsonFacet
constructor
A new instance of RangeJsonFacet.
Methods inherited from AbstractJsonFieldFacet
#get_params, #init_params, #to_params
Constructor Details
#initialize(field, options, setup) ⇒ RangeJsonFacet
Returns a new instance of RangeJsonFacet.
7 8 9 10 11 12 13 14 15 |
# File 'lib/sunspot/query/range_json_facet.rb', line 7 def initialize(field, , setup) [:range] ||= [:time_range] raise Exception.new("Need to specify a range") if [:range].nil? && [:time_range].nil? @start = [:range].first @end = [:range].last @gap = [:gap] || SECONDS_IN_DAY @other = [:other] super end |
Instance Method Details
#field_name_with_local_params ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/sunspot/query/range_json_facet.rb', line 17 def field_name_with_local_params { @field.name => { type: 'range', field: @field.indexed_name, start: @field.to_indexed(@start), end: @field.to_indexed(@end), gap: @gap, other: @other }.merge!(init_params) } end |