5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
# File 'lib/rsolr-ext/request.rb', line 5
def map input_params
input = input_params.dup
output = {}
if input[:per_page]
output[:rows] = input.delete(:per_page).to_i
end
if page = input.delete(:page)
raise ':per_page must be set when using :page' unless output[:rows]
page = page.to_s.to_i-1
page = page < 1 ? 0 : page
output[:start] = page * output[:rows]
end
output[:q] = input.delete :q
output[:fq] = input.delete(:fq) if input[:fq]
if queries = input.delete(:queries)
output[:q] = append_to_param output[:q], build_query(queries, false)
end
if phrases = input.delete(:phrases)
output[:q] = append_to_param output[:q], build_query(phrases, true)
end
if filters = input.delete(:filters)
output[:fq] = append_to_param output[:fq], build_query(filters), false
end
if phrase_filters = input.delete(:phrase_filters)
output[:fq] = append_to_param output[:fq], build_query(phrase_filters, true), false
end
if facets = input.delete(:facets)
output[:facet] = true
output['facet.field'] = append_to_param output['facet.field'], build_query(facets.values), false
end
output.merge input
end
|