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
68
69
70
|
# File 'lib/sunspot/query/common_query.rb', line 68
def [](key)
to_params[key.to_sym]
end
|
#add_field_facet(facet) ⇒ Object
28
29
30
31
|
# File 'lib/sunspot/query/common_query.rb', line 28
def add_field_facet(facet)
@components << facet
facet
end
|
#add_function(function) ⇒ Object
38
39
40
41
|
# File 'lib/sunspot/query/common_query.rb', line 38
def add_function(function)
@components << function
function
end
|
#add_geo(geo) ⇒ Object
43
44
45
46
|
# File 'lib/sunspot/query/common_query.rb', line 43
def add_geo(geo)
@components << geo
geo
end
|
#add_group(group) ⇒ Object
23
24
25
26
|
# File 'lib/sunspot/query/common_query.rb', line 23
def add_group(group)
@components << group
group
end
|
#add_query_facet(facet) ⇒ Object
33
34
35
36
|
# File 'lib/sunspot/query/common_query.rb', line 33
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
72
73
74
|
# File 'lib/sunspot/query/common_query.rb', line 72
def page
@pagination.page if @pagination
end
|
#paginate(page, per_page, offset = nil) ⇒ Object
48
49
50
51
52
53
54
55
56
|
# File 'lib/sunspot/query/common_query.rb', line 48
def paginate(page, per_page, offset = nil)
if @pagination
@pagination.offset = offset
@pagination.page = page
@pagination.per_page = per_page
else
@components << @pagination = Pagination.new(page, per_page, offset)
end
end
|
#per_page ⇒ Object
76
77
78
|
# File 'lib/sunspot/query/common_query.rb', line 76
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
58
59
60
61
62
63
64
65
66
|
# File 'lib/sunspot/query/common_query.rb', line 58
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
|