Commits

lakin.wecker committed 660cd82 Draft

fixing the ListMatcher.skip_to_quality. There are two issues here. 1 - it ALWAYS skips at least one element - which I think is incorrect. Next, it refers to .quality() an attribute which does not exist. I believe that should be .block_quality().

Comments (0)

Files changed (2)

src/whoosh/matching/mcore.py

         return self._scorer.block_quality(self)
 
     def skip_to_quality(self, minquality):
-        self._i += 1
-        while self._i < len(self._ids) and self.quality() <= minquality:
+        while self._i < len(self._ids) and self.block_quality() <= minquality:
             self._i += 1
         return 0
 

tests/test_matching.py

 from whoosh.filedb.filestore import RamStorage
 from whoosh.query import And, Term
 from whoosh.util import make_binary_tree
+from whoosh.scoring import WeightScorer
 
 
 def _keys(searcher, docnums):
     assert_equal(ls, [9, 10])
 
 
+def test_listmatcher_skip_to_quality_identical_scores():
+    ids = [1, 2, 5, 9, 10]
+
+    lm = matching.ListMatcher(ids, scorer=WeightScorer(1.0))
+    lm.skip_to_quality(0.3)
+    ls = []
+    while lm.is_active():
+        ls.append((lm.id(), lm.score()))
+        lm.next()
+    assert_equal(ls, [(1, 1.0), (2, 1.0), (5, 1.0), (9, 1.0), (10, 1.0)])
+
+
 def test_wrapper():
     wm = matching.WrappingMatcher(matching.ListMatcher([1, 2, 5, 9, 10]),
                                   boost=2.0)