Method: Sunspot::DSL::Scope#dynamic

Defined in:
lib/sunspot/dsl/scope.rb

#dynamic(base_name, &block) ⇒ Object

Apply restrictions, facets, and ordering to dynamic field instances. The block API is implemented by Sunspot::DSL::FieldQuery, which is a superclass of the Query DSL (thus providing a subset of the API, in particular only methods that refer to particular fields).

Parameters

base_name<Symbol>

The base name for the dynamic field definition

Example

Sunspot.search Post do
  dynamic :custom do
    with :cuisine, 'Pizza'
    facet :atmosphere
    order_by :chef_name
  end
end


188
189
190
# File 'lib/sunspot/dsl/scope.rb', line 188

def dynamic(base_name, &block)
  FieldQuery.new(@query.dynamic_query(base_name)).instance_eval(&block)
end