Sha256: fa7b3a4d60e080780f667a83ce10632ddbad0d87ee688c9a421dd4faad6ecbb4
Contents?: true
Size: 1.36 KB
Versions: 20
Compression:
Stored size: 1.36 KB
Contents
module Sunspot module Query class RangeFacet < AbstractFieldFacet 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 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 private def local_params @local_params ||= begin local_params = {} local_params[:ex] = @exclude_tag if @exclude_tag local_params[:key] = @options[:name] if @options[:name] local_params end end def field_name_with_local_params if local_params.empty? @field.indexed_name else pairs = local_params.map do |key, value| "#{key}=#{value}" end "{!#{pairs.join(' ')}}#{@field.indexed_name}" end end end end end
Version data entries
20 entries across 20 versions & 2 rubygems