Sha256: 6345237c85f153995f9ad903aa88ed026066d7098f1b9cb4e8113b093fd0d43a

Contents?: true

Size: 596 Bytes

Versions: 11

Compression:

Stored size: 596 Bytes

Contents

module Sunspot
  module Query
    class FieldStats
      def initialize(field, options)
        @field, @options = field, options
        @facets = []
      end

      def add_facet field
        @facets << field
      end

      def to_params
        params = { :stats => true, :"stats.field" => [@field.indexed_name]}
        params[facet_key] = @facets.map(&:indexed_name) unless @facets.empty?
        params
      end

      def facet_key
        qualified_param 'facet'
      end

      def qualified_param name
        :"f.#{@field.indexed_name}.stats.#{name}"
      end
    end
  end
end

Version data entries

11 entries across 11 versions & 2 rubygems

Version Path
sunspot-2.2.8 lib/sunspot/query/field_stats.rb
enju_leaf-1.2.1 vendor/bundle/ruby/2.3/gems/sunspot-2.2.7/lib/sunspot/query/field_stats.rb
sunspot-2.2.7 lib/sunspot/query/field_stats.rb
sunspot-2.2.6 lib/sunspot/query/field_stats.rb
sunspot-2.2.5 lib/sunspot/query/field_stats.rb
sunspot-2.2.4 lib/sunspot/query/field_stats.rb
sunspot-2.2.3 lib/sunspot/query/field_stats.rb
sunspot-2.2.2 lib/sunspot/query/field_stats.rb
sunspot-2.2.1 lib/sunspot/query/field_stats.rb
sunspot-2.2.0 lib/sunspot/query/field_stats.rb
sunspot-2.1.1 lib/sunspot/query/field_stats.rb