From 2969a749533c1214a2a7bcb80d7d1b60f67f3381 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jorge=20C=2E=20Leit=C3=A3o?= Date: Sat, 17 May 2014 13:16:16 +0200 Subject: [PATCH] Refactored _filter_exact query constructor. Its interface is explained in the docstring. --- xapian_backend.py | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/xapian_backend.py b/xapian_backend.py index 0d827a5..b057da8 100755 --- a/xapian_backend.py +++ b/xapian_backend.py @@ -1121,18 +1121,14 @@ class XapianSearchQuery(BaseSearchQuery): def _filter_exact(self, term, field_name, field_type, is_not): """ - Private method that returns a xapian.Query that searches for an exact - match for `term` in a specified `field`. - - Required arguments: - ``term`` -- The term to search for - ``field`` -- The field to search - ``is_not`` -- Invert the search results - - Returns: - A xapian.Query + Returns a query that matches exactly the un-stemmed term + with positional order. """ - query = self._phrase_query(term.split(), field_name) + if ' ' in term: + query = self._phrase_query(term.split(), field_name) + else: + query = self._term_query(term, field_name, field_type, exact=True) + if is_not: return xapian.Query(xapian.Query.OP_AND_NOT, self._all_query(), query) else: