Class: Sunspot::Query::DynamicQuery

Inherits:
FieldQuery show all
Defined in:
lib/sunspot/query/dynamic_query.rb

Overview

A dynamic query is a proxy object that implements the API of the FieldQuery class, but wraps a dynamic field factory and thus applies the query components using dynamic field instances. – Dynamic queries do not hold their own state, but rather proxy to the query that generated them, adding components directly to the owning query’s internal state. ++ DynamicQuery instances are publicly generated by the Query#dynamic_query factory method.

Instance Method Summary collapse

Methods inherited from FieldQuery

#add_field_facet, #add_query_facet, #order_by

Methods inherited from Scope

#add_conjunction, #add_disjunction, #add_negated_restriction, #add_negated_shorthand_restriction, #add_restriction, #add_shorthand_restriction

Constructor Details

#initialize(dynamic_field_factory, query) ⇒ DynamicQuery

:nodoc:



16
17
18
# File 'lib/sunspot/query/dynamic_query.rb', line 16

def initialize(dynamic_field_factory, query) #:nodoc:
  @dynamic_field_factory, @query = dynamic_field_factory, query
end

Instance Method Details

#add_component(component) ⇒ Object

Add a component to the query



46
47
48
# File 'lib/sunspot/query/dynamic_query.rb', line 46

def add_component(component) #:nodoc:
  @query.add_component(component)
end

#add_sort(sort) ⇒ Object

Add a Sort to the query



39
40
41
# File 'lib/sunspot/query/dynamic_query.rb', line 39

def add_sort(sort) #:nodoc:
  @query.add_sort(sort)
end

#dynamic_query(field_name) ⇒ Object

This has the same effect as calling Query#exclude_instance; it is included for interface completeness.



32
33
34
# File 'lib/sunspot/query/dynamic_query.rb', line 32

def dynamic_query(field_name)
  @query.dynamic_query(field_name)
end

#exclude_instance(instance) ⇒ Object

This has the same effect as calling Query#exclude_instance; it is included for interface completeness.



24
25
26
# File 'lib/sunspot/query/dynamic_query.rb', line 24

def exclude_instance(instance)
  @query.exclude_instance(instance)
end