I have created an index and created documents as per documentation.
But when I am running the script do I always have to go through the process of adding the document and then search for the string.
Is it possible to store it once and then I can search for the terms again and again?
Once you've created an index, you can reuse that index (assuming you've saved it).
In Whoosh, you can reopen a previously-generated index like so:
import whoosh.index as index
ix = index.open_dir("dir/to/index")
Here, ix
is an Index
object. The file path is the same you used to create the index using create_in
. You can then create a Searcher
object ( ix.searcher()
) and begin searching, just as you probably learned in the "Quick start" .
See "How to index documents" for more information.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.