Sha256: e1edc2908f0c92f9a1575aad407393ac289a21a92db444de3fb797e0d11b263c

Contents?: true

Size: 696 Bytes

Versions: 3

Compression:

Stored size: 696 Bytes

Contents

module Sunspot
  module DSL
    # 
    # Provides an API for areas of the query DSL that operate on specific
    # fields. This functionality is provided by the query DSL and the dynamic
    # query DSL.
    #
    class FieldQuery < Scope
      def initialize(search, query, setup) #:nodoc:
        @search, @query = search, query
        super(query.scope, setup)
      end

      def stat(field_name, options = {})
        field = @setup.field(field_name)
        options[:facet] = @setup.field(options[:facet]) if !options[:facet].nil?
        stat = @query.add_stat(Sunspot::Query::FieldStat.new(field, options))
        @search.add_field_stat(field, options)
      end
    end    
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
sunspot_stats-0.0.5 lib/dsl/field_query.rb
sunspot_stats-0.0.4 lib/dsl/field_query.rb
sunspot_stats-0.0.3 lib/dsl/field_query.rb