我是一個完整的Python新手,以及Whoosh。開始使用Python上的Whoosh
我需要創建一個搜索引擎,允許我在XML文件中進行搜索。對於這一點,我已經下載並嗖的一聲從命令提示符
setup.py build
setup.py install
然後我拿了一個示例代碼從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]
而且我正在爲QueryParser
的Unresolved import error:create_in
和同爲好。
我不確定是否需要添加一些路徑變量。沒有足夠的關於開始使用Whoosh的文檔,相反,有越來越多的示例代碼。
在此先感謝!
嗖文檔現在的位置是:HTTPS://whoosh.readthedocs。 io/en/latest/ –