Skip to content

Commit

Permalink
Merge 42ab6eb into 1d1b9eb
Browse files Browse the repository at this point in the history
  • Loading branch information
emptyflash committed Jul 18, 2019
2 parents 1d1b9eb + 42ab6eb commit bca0da4
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
2 changes: 1 addition & 1 deletion luqum/__init__.py
@@ -1,4 +1,4 @@
# -*- coding: utf-8 -*-

__version__ = '0.7.5'
__version__ = '0.8.0'
__version_info__ = tuple(__version__.split('.'))
12 changes: 8 additions & 4 deletions luqum/elasticsearch/tree.py
Expand Up @@ -38,8 +38,10 @@ def __init__(self, no_analyze=None, method='term', fields=[], _name=None, field_
def json(self):
field = self.field
inner_json = dict(self.field_options.get(field, {}))
inner_json.pop('type', None) # remove "type" key
if self.method == 'query_string':
result = inner_json.pop('match_type', None) # remove "match_type" key
if not result: # conditionally remove "type" (for backward compatibility)
inner_json.pop('type', None)
if self.method in ['query_string', 'multi_match']:
json = {self.method: inner_json}
else:
json = {self.method: {field: inner_json}}
Expand All @@ -50,7 +52,7 @@ def json(self):
value = getattr(self, key, None)
if value is not None:
if key == 'q':
if self.method.startswith('match'):
if 'match' in self.method:
inner_json['query'] = value
if self.method == 'match':
inner_json['zero_terms_query'] = self.zero_terms_query
Expand Down Expand Up @@ -94,7 +96,9 @@ def method(self):
if self._value_has_wildcard_char():
return 'query_string'
elif self._method.startswith("match"):
return self.field_options.get(self.field, {}).get("type", self._method)
options = self.field_options.get(self.field, {})
# Support the type opiton for backward compatibility
return options.get("match_type", options.get("type", self._method))
return self._method


Expand Down

0 comments on commit bca0da4

Please sign in to comment.