I am a complete newbie to to python as well as Whoosh.
I need to create a search engine that allows me to search inside an XML file. For that, I have downloaded Whoosh and from the command prompt
setup.py build
setup.py install
I then took a sample code from the http://pythonhosted.org/Whoosh/quickstart.html
from whoosh.index import create_in
from whoosh.fields import *
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()
from whoosh.qparser import QueryParser
with ix.searcher() as searcher:
query = QueryParser("content", ix.schema).parse("first")
results = searcher.search(query)
results[0]
And I am getting an Unresolved import error:create_in
and the same for QueryParser
as well.
I am not sure if I have to add some path variables. There was not enough documentation on getting started with Whoosh, rather, there are more and more sample codes.
Thanks in advance!