1. Matt Chaput
  2. whoosh
  3. Issues
Issue #356 resolved

KeyError when trying to collapse results

Michael Elsdörfer
created an issue

Using 2.5.2

This is the schema:

schema = Schema(
        # sortable because we collapse on it
        version=ID(unique=True, stored=True, sortable=True),
        page=ID(stored=True, sortable=True),
        title=TEXT(stored=True, field_boost=2, spelling=True),
        content=TEXT(stored=True, spelling=True),

This is how I search:

index = open_index(self.app, readonly=False)
        searcher = index.searcher()
        qparser = MultifieldParser(['title', 'content'], index.schema)
        results = searcher.search(
            query.And([qparser.parse(unicode(q)) for q in ns.query]),
                FieldFacet('published', reverse=True),
                FieldFacet('version', reverse=True)

This is the exception I see:

  File "/Users/michael/.virtualenvs/cms/lib/python2.7/site-packages/whoosh/searching.py", line 787, in search
    self.search_with_collector(q, c)
  File "/Users/michael/.virtualenvs/cms/lib/python2.7/site-packages/whoosh/searching.py", line 820, in search_with_collector
  File "/Users/michael/.virtualenvs/cms/lib/python2.7/site-packages/whoosh/collectors.py", line 143, in run
  File "/Users/michael/.virtualenvs/cms/lib/python2.7/site-packages/whoosh/collectors.py", line 979, in collect_matches
  File "/Users/michael/.virtualenvs/cms/lib/python2.7/site-packages/whoosh/collectors.py", line 497, in remove
    raise KeyError(global_docnum)
KeyError: 2084L

Note that this error occurs for most search terms - but not all. Some work fine, and they do so even if collapsing is going on.

Comments (6)

  1. Log in to comment