From 89691ce86a279b109c65f750a7738ae0f432049f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jorge=20C=2E=20Leit=C3=A3o?= Date: Sat, 17 May 2014 13:21:39 +0200 Subject: [PATCH] Added method to create OR queries from list of strings. --- xapian_backend.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/xapian_backend.py b/xapian_backend.py index c138513..a5da57e 100755 --- a/xapian_backend.py +++ b/xapian_backend.py @@ -1139,6 +1139,13 @@ class XapianSearchQuery(BaseSearchQuery): return xapian.Query(xapian.Query.OP_AND_NOT, self._all_query(), query) return query + def _or_query(self, term_list, field, field_type, exact=False): + """ + Joins each item of term_list decorated by _term_query with an OR. + """ + term_list = [self._term_query(term, field, field_type, exact) for term in term_list] + return xapian.Query(xapian.Query.OP_OR, term_list) + def _phrase_query(self, term_list, field_name): """ Returns a query that matches exact terms and with