Skip to content

Commit

Permalink
Fix BooleanIndex to filter out missing documents, refs #28.
Browse files Browse the repository at this point in the history
  • Loading branch information
hannosch committed Oct 4, 2017
1 parent 6f1c82a commit 374131c
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 1 deletion.
3 changes: 3 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ Changelog
3.2.1 (unreleased)
------------------

- Fix a bug in the BooleanIndex where documents without an entry in
the index were not being filtered out in all queries.

- #19: Fix stale cache results after clearing an index.

3.2 (2016-07-18)
Expand Down
1 change: 1 addition & 0 deletions buildout.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ parts = interpreter test

[versions]
Products.ZCatalog =
five.globalrequest = < 99.0.dev

[interpreter]
recipe = zc.recipe.egg
Expand Down
4 changes: 3 additions & 1 deletion src/Products/PluginIndexes/BooleanIndex/BooleanIndex.py
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,9 @@ def _apply_index(self, request, resultset=None):
return (union(difference(self._unindex, index), IISet([])),
(self.id, ))
else:
return (difference(resultset, index), (self.id, ))
return (intersection(difference(resultset, index),
self._unindex),
(self.id, ))
return (IISet(), (self.id, ))

def indexSize(self):
Expand Down
8 changes: 8 additions & 0 deletions src/Products/PluginIndexes/BooleanIndex/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,14 @@ def test_search_inputresult(self):
self.assertEqual(idx, ('truth', ))
self.assertEqual(list(res), [2])

res, idx = index._apply_index({'truth': True},
resultset=IISet([1, 2, 99]))
self.assertEqual(list(res), [1])

res, idx = index._apply_index({'truth': False},
resultset=IISet([1, 2, 99]))
self.assertEqual(list(res), [2])

def test_index_many_true(self):
index = self._makeOne()
for i in range(0, 100):
Expand Down

0 comments on commit 374131c

Please sign in to comment.