Class: Sunspot::Query::BaseQuery
- Inherits:
-
Object
- Object
- Sunspot::Query::BaseQuery
- Includes:
- RSolr::Char
- Defined in:
- lib/sunspot/query/base_query.rb
Overview
Encapsulates information common to all queries - in particular, types. Subclassed by FulltextBaseQuery, which puts the types in a filter query and sets up dismax search.
Direct Known Subclasses
Instance Attribute Summary collapse
-
#keywords ⇒ Object
writeonly
Sets the attribute keywords.
-
#phrase_fields ⇒ Object
writeonly
Sets the attribute phrase_fields.
-
#types ⇒ Object
readonly
Returns the value of attribute types.
Instance Method Summary collapse
-
#initialize(types, setup) ⇒ BaseQuery
constructor
A new instance of BaseQuery.
-
#to_params ⇒ Object
Generate params for the base query.
Constructor Details
#initialize(types, setup) ⇒ BaseQuery
Returns a new instance of BaseQuery.
15 16 17 |
# File 'lib/sunspot/query/base_query.rb', line 15 def initialize(types, setup) @types, @setup = types, setup end |
Instance Attribute Details
#keywords=(value) ⇒ Object (writeonly)
Sets the attribute keywords
12 13 14 |
# File 'lib/sunspot/query/base_query.rb', line 12 def keywords=(value) @keywords = value end |
#phrase_fields=(value) ⇒ Object (writeonly)
Sets the attribute phrase_fields
13 14 15 |
# File 'lib/sunspot/query/base_query.rb', line 13 def phrase_fields=(value) @phrase_fields = value end |
#types ⇒ Object (readonly)
Returns the value of attribute types.
11 12 13 |
# File 'lib/sunspot/query/base_query.rb', line 11 def types @types end |
Instance Method Details
#to_params ⇒ Object
Generate params for the base query. If keywords are specified, build params for a dismax query, request all stored fields plus the score, and put the types in a filter query. If keywords are not specified, put the types query in the q parameter.
25 26 27 |
# File 'lib/sunspot/query/base_query.rb', line 25 def to_params { :q => types_phrase } end |