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!
I strongly recommend using a module installer like easy_install or PIP instead of manual installation of modules as it will save you from a lot of problems and issues (like this one, after installing whoosh with pip the imports are working very well for me).
You can learn how to install pip on the official site http://www.pip-installer.org/en/latest/installing.html and after you've done it - getting whoosh is as simple as
pip install whoosh