Class: MmEsSearch::Api::Query::NestedQuery
Instance Method Summary
collapse
#es_abs_field, #mongo_abs_field, #path_and_index, #to_filter
Instance Method Details
#to_es_query ⇒ Object
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
# File 'lib/mm_es_search/api/query/nested_query.rb', line 25
def to_es_query
mod_path, array_index = path_and_index
mod_query = if array_index.nil?
query
else
query_array = [
query,
TermQuery.new(:path => mod_path, :field => array_index_name || '_array_index', :value => array_index)]
anded_query(query_array)
end
nested_params = {
es_api_keyword => mod_query.to_es_query,
:path => mod_path
}
nested_params.merge!({:score_mode => score_mode}) unless score_mode.nil?
nested_params.merge!({:_scope => _scope}) unless _scope.nil?
return {:nested => nested_params}
end
|
#to_mongo_query(options = {}) ⇒ Object
13
14
15
16
17
18
19
20
21
22
23
|
# File 'lib/mm_es_search/api/query/nested_query.rb', line 13
def to_mongo_query(options = {})
mod_path, array_index = path_and_index
if array_index.nil?
{path.split('.').last => {'$elemMatch' => query.to_mongo_query(options)}}
else
query.to_mongo_query(options) end
end
|