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 ce02fc1 commit 7d246f2
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
2 changes: 2 additions & 0 deletions CHANGES.txt
Expand Up @@ -4,6 +4,8 @@ Changelog
2.13.28 (unreleased)
--------------------

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

2.13.27 (2014-02-19)
--------------------
Expand Down
4 changes: 3 additions & 1 deletion src/Products/PluginIndexes/BooleanIndex/BooleanIndex.py
Expand Up @@ -229,7 +229,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
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 7d246f2

Please sign in to comment.