python - Saving the index in Whoosh -
i looking suggestion or preferably example, store or save index of whoosh. using python 2.7 on windows 7 professional. if may kindly help.
whoosh documented , can find of things in official documentation. here example of indexer-searcher quick start:
# indexer >>> whoosh.index import create_in >>> 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 first document we've added!") >>> writer.add_document(title=u"second document", path=u"/b", ... content=u"the second 1 more interesting!") >>> writer.commit() # searcher >>> whoosh.qparser import queryparser >>> ix.searcher() searcher: ... query = queryparser("content", ix.schema).parse("first") ... results = searcher.search(query) ... results[0] ... {"title": u"first document", "path": u"/a"}
the example explained in details there.
Comments
Post a Comment