--- a/mozautoeslib/eslib.py
+++ b/mozautoeslib/eslib.py
@@ -69,17 +69,17 @@ class ESLib(object):
boolquery = BoolQuery()
self._add_fieldlist_to_boolquery(boolquery, include, True)
self._add_fieldlist_to_boolquery(boolquery, exclude, False)
if sort:
boolquery.sort = sort
return boolquery
- def ORQuery(self, ORItems, size=10000, doc_type=None):
+ def ORQuery(self, ORItems, size=10000, doc_type=None, useFieldQueries=False):
"""Return a list of hits that match any of the combination of terms
specified in the ORItems list of dicts.
Example:
return hits that match any of the following mahine/starttime
combinations:
result = eslib.ORQuery([
@@ -92,17 +92,20 @@ class ESLib(object):
self.doc_type = doc_type
resultlist = []
orList = []
for item in ORItems:
andList = []
for key in item:
- andList.append(TermFilter(key, item[key]))
+ if useFieldQueries:
+ andList.append(QueryFilter(FieldQuery(FieldParameter(key, item[key]))))
+ else:
+ andList.append(TermFilter(key, item[key]))
orList.append(ANDFilter(andList))
orq = ORFilter(orList)
q = FilteredQuery(MatchAllQuery(), orq)
result = self.connection.search(query=q,
size=size,
indexes=[self.index],
doc_types=self.doc_type)