Here is my complete script (the demo in the docs needs updating as it
doesn't work at the moment):
#------------
import os
from whoosh.index import create_in
from whoosh.fields import *
from whoosh.qparser import QueryParser
try:
os.mkdir("indexdir")
except OSError:
pass # assume already exists...
schema = Schema(title=TEXT(stored=True), path=ID(stored=True),
content=TEXT)
ix = create_in("indexdir", schema)
writer = ix.writer()
writer.add_document(title=u"First document", path=u"/a",
content=u"This is the first document we've
added!")
writer.add_document(title=u"Second document", path=u"/b",
content=u"The second one is even more
interesting!")
writer.commit()
with ix.searcher() as searcher:
query = QueryParser("content", ix.schema).parse(u"first")
results = searcher.search(query)
print results[0]
#------------