Traceback when no segments exist in index

Issue #31 resolved
Peter Hansen
created an issue

The following code demonstrates a failure with 1.0.0b9 (and perhaps earlier) when you create an index but don't add any documents and then try to search it. The problem seems to come from code in {{{fileindex.SegmentSet.reader()}}} which doesn't handle the no-segment case gracefully.

from whoosh import index
from whoosh.fields import Schema, TEXT

schema = Schema(text=TEXT())

ix = index.create_in('.', schema)
search = ix.searcher()
search.find('text', u'foo')

This gives a traceback ending with this:
File ".....\whoosh\", line 264, in find
qp = QueryParser(defaultfield, schema=self.ixreader.schema)
AttributeError: 'MultiReader' object has no attribute 'schema'

Comments (1)

  1. Log in to comment