Class: MmEsSearch::Api::Query::PrefixQuery
Instance Method Summary
collapse
#es_abs_field, #mongo_abs_field, #path_and_index, #to_filter
Instance Method Details
#to_es_query ⇒ Object
22
23
24
25
26
27
28
|
# File 'lib/mm_es_search/api/query/prefix_query.rb', line 22
def to_es_query
if boost
{:prefix => {es_abs_field => {:value => value, :boost => boost}}}
else
{:prefix => {es_abs_field => value}}
end
end
|
#to_mongo_query(options = {}) ⇒ Object
13
14
15
16
17
18
19
20
|
# File 'lib/mm_es_search/api/query/prefix_query.rb', line 13
def to_mongo_query(options = {})
prefix_regex = /^#{value}/
if options[:negated]
{mongo_abs_field => {'$ne' => prefix_regex}}
else
{mongo_abs_field => prefix_regex}
end
end
|