Commit 9e60a62b by Michael Frey Committed by GitHub

Merge pull request #224 from edx/mjfrey/wrap_query

Wrap ES search query in parens to perserve semantics
parents 1a323089 8f7527f6
...@@ -13,6 +13,10 @@ def clean_query(query): ...@@ -13,6 +13,10 @@ def clean_query(query):
# Ensure the query is lowercase, since that is how we index our data. # Ensure the query is lowercase, since that is how we index our data.
query = query.lower() query = query.lower()
# Specifying a SearchQuerySet filter will append an explicit AND clause to the query, thus changing its semantics.
# So we wrap parentheses around the original query in order to preserve the semantics.
query = '({qs})'.format(qs=query)
# Ensure all operators are uppercase # Ensure all operators are uppercase
for operator in RESERVED_ELASTICSEARCH_QUERY_OPERATORS: for operator in RESERVED_ELASTICSEARCH_QUERY_OPERATORS:
old = ' {0} '.format(operator.lower()) old = ' {0} '.format(operator.lower())
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment