Class: Sunspot::Query::CommonQuery
- Inherits:
-
Object
- Object
- Sunspot::Query::CommonQuery
show all
- Defined in:
- lib/sunspot/query/common_query.rb
Instance Method Summary
collapse
Constructor Details
Returns a new instance of CommonQuery.
Instance Method Details
#[](key) ⇒ Object
57
58
59
|
# File 'lib/sunspot/query/common_query.rb', line 57
def [](key)
to_params[key.to_sym]
end
|
#add_field_facet(facet) ⇒ Object
23
24
25
26
|
# File 'lib/sunspot/query/common_query.rb', line 23
def add_field_facet(facet)
@components << facet
facet
end
|
#add_function(function) ⇒ Object
33
34
35
36
|
# File 'lib/sunspot/query/common_query.rb', line 33
def add_function(function)
@components << function
function
end
|
#add_query_facet(facet) ⇒ Object
28
29
30
31
|
# File 'lib/sunspot/query/common_query.rb', line 28
def add_query_facet(facet)
@components << facet
facet
end
|
#add_sort(sort) ⇒ Object
19
20
21
|
# File 'lib/sunspot/query/common_query.rb', line 19
def add_sort(sort)
@sort << sort
end
|
#page ⇒ Object
61
62
63
|
# File 'lib/sunspot/query/common_query.rb', line 61
def page
@pagination.page if @pagination
end
|
#paginate(page, per_page) ⇒ Object
38
39
40
41
42
43
44
45
|
# File 'lib/sunspot/query/common_query.rb', line 38
def paginate(page, per_page)
if @pagination
@pagination.page = page
@pagination.per_page = per_page
else
@components << @pagination = Pagination.new(page, per_page)
end
end
|
#per_page ⇒ Object
65
66
67
|
# File 'lib/sunspot/query/common_query.rb', line 65
def per_page
@pagination.per_page if @pagination
end
|
#solr_parameter_adjustment=(block) ⇒ Object
15
16
17
|
# File 'lib/sunspot/query/common_query.rb', line 15
def solr_parameter_adjustment=(block)
@parameter_adjustment = block
end
|
#to_params ⇒ Object
47
48
49
50
51
52
53
54
55
|
# File 'lib/sunspot/query/common_query.rb', line 47
def to_params
params = {}
@components.each do |component|
Sunspot::Util.deep_merge!(params, component.to_params)
end
@parameter_adjustment.call(params) if @parameter_adjustment
params[:q] ||= '*:*'
params
end
|