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
43
44
45
46
|
# File 'lib/s3search/api/searches.rb', line 17
def search options
raise 'where: {field: "value"} is a required option' unless options[:where]
query_terms = options.delete(:where).map do |field, value|
{
query_string: {
default_field: field,
query: value,
default_operator: 'AND'
}
}
end
query = {
query: {
bool: {
must: query_terms
}
}
}
page = options.delete(:page) || 1
per_page = options.delete(:per_page) || 25
query.merge!(options)
response = _post '/v1/searches.json', {
search: query,
page: page,
per_page: per_page
}
S3Search::ResultPage.new(response, self)
end
|