mirror of
https://github.com/Hopiu/xapian-haystack.git
synced 2026-04-22 15:44:51 +00:00
Converted model filtering to use pure boolean subquery
This commit is contained in:
parent
2a4b32f03b
commit
184f10af2d
2 changed files with 8 additions and 6 deletions
|
|
@ -114,7 +114,7 @@ class XapianSearchQueryTestCase(TestCase):
|
|||
def test_build_query_with_models(self):
|
||||
self.sq.add_filter(SQ(content='hello'))
|
||||
self.sq.add_model(MockModel)
|
||||
self.assertEqual(self.sq.build_query().get_description(), 'Xapian::Query((hello AND XCONTENTTYPEcore.mockmodel))')
|
||||
self.assertEqual(self.sq.build_query().get_description(), 'Xapian::Query((hello AND 0 * XCONTENTTYPEcore.mockmodel))')
|
||||
|
||||
self.sq.add_model(AnotherMockModel)
|
||||
self.assertEqual(self.sq.build_query().get_description(), 'Xapian::Query((hello AND (XCONTENTTYPEcore.anothermockmodel OR XCONTENTTYPEcore.mockmodel)))')
|
||||
self.assertEqual(self.sq.build_query().get_description(), 'Xapian::Query((hello AND (0 * XCONTENTTYPEcore.anothermockmodel OR 0 * XCONTENTTYPEcore.mockmodel)))')
|
||||
|
|
|
|||
|
|
@ -890,10 +890,12 @@ class SearchQuery(BaseSearchQuery):
|
|||
|
||||
if self.models:
|
||||
subqueries = [
|
||||
xapian.Query('%s%s.%s' % (
|
||||
DOCUMENT_CT_TERM_PREFIX,
|
||||
model._meta.app_label, model._meta.module_name
|
||||
)
|
||||
xapian.Query(
|
||||
xapian.Query.OP_SCALE_WEIGHT, xapian.Query('%s%s.%s' % (
|
||||
DOCUMENT_CT_TERM_PREFIX,
|
||||
model._meta.app_label, model._meta.module_name
|
||||
)
|
||||
), 0
|
||||
) for model in self.models
|
||||
]
|
||||
query = xapian.Query(
|
||||
|
|
|
|||
Loading…
Reference in a new issue