Class: Sunspot::DSL::FieldQuery

Inherits:
Scope
  • Object
show all
Defined in:
lib/dsl/field_query.rb

Overview

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.

Instance Method Summary collapse

Constructor Details

#initialize(search, query, setup) ⇒ FieldQuery

:nodoc:



9
10
11
12
# File 'lib/dsl/field_query.rb', line 9

def initialize(search, query, setup) #:nodoc:
  @search, @query = search, query
  super(query.scope, setup)
end

Instance Method Details

#stat(field_name, options = {}) ⇒ Object



14
15
16
17
18
19
# File 'lib/dsl/field_query.rb', line 14

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