Matt Chaput avatar Matt Chaput committed 66704ae

Removed erroneous KeyError from TopCollector.remove().
Fixes issue #356.

Comments (0)

Files changed (1)

src/whoosh/collectors.py

         negated = 0 - global_docnum
         items = self.items
 
-        # Search through the results for the document and remove it
+        # Remove the document if it's on the list (it may not be since
+        # TopCollector forgets documents that don't make the top N list)
         for i in xrange(len(items)):
             if items[i][1] == negated:
                 items.pop(i)
                 self.minscore = items[0][0] if items else 0
                 return
 
-        # The document wasn't on the list... somebody's confused!
-        raise KeyError(global_docnum)
-
     def results(self):
         # The items are stored (postive score, negative docnum) so the heap
         # keeps the highest scores and lowest docnums, in order from lowest to
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.