SearchQuery._term_query will now properly build a query for field id and django_ct

This commit is contained in:
David Sauve 2010-08-10 10:15:35 -07:00
parent 5180f5f00c
commit ea60ae1ffe
2 changed files with 20 additions and 16 deletions

View file

@ -13,6 +13,7 @@ Code Changes
* Changed `SearchBackend.update` method to index terms with punctuation as well as using the Xapian.TermGenerator.
* Fixed another occurrence of DatabaseModifiedError
* Updated for compatibility with Xapian 1.2 by removing deprecated method calls and slightly refactoring the way queries are constructed.
* SearchQuery._term_query will now properly build a query for field `id` and `django_ct` fields.
Known Issues
------------

View file

@ -1114,24 +1114,27 @@ class SearchQuery(BaseSearchQuery):
A xapian.Query
"""
stem = xapian.Stem(self.backend.language)
if field:
return xapian.Query(
xapian.Query.OP_OR,
xapian.Query('Z%s%s%s' % (
DOCUMENT_CUSTOM_TERM_PREFIX, field.upper(), stem(term)
)
),
xapian.Query('%s%s%s' % (
DOCUMENT_CUSTOM_TERM_PREFIX, field.upper(), term
)
)
if field == 'id':
return xapian.Query('%s%s' % (DOCUMENT_ID_TERM_PREFIX, term))
elif field == 'django_ct':
return xapian.Query('%s%s' % (DOCUMENT_CT_TERM_PREFIX, term))
elif field:
stemmed = 'Z%s%s%s' % (
DOCUMENT_CUSTOM_TERM_PREFIX, field.upper(), stem(term)
)
unstemmed = '%s%s%s' % (
DOCUMENT_CUSTOM_TERM_PREFIX, field.upper(), term
)
else:
return xapian.Query(
xapian.Query.OP_OR,
xapian.Query('Z%s' % stem(term)),
xapian.Query(term)
)
stemmed = 'Z%s' % stem(term)
unstemmed = term
return xapian.Query(
xapian.Query.OP_OR,
xapian.Query(stemmed),
xapian.Query(unstemmed)
)
def _phrase_query(self, term_list, field=None):
"""