0

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?

blackmamba
  • 1,952
  • 11
  • 34
  • 59

1 Answers1

1

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.

Jacob Budin
  • 9,753
  • 4
  • 32
  • 35
  • But when I do that my search are limited to 3. In case of create_in I get 6 results (I added a limit of 6) – blackmamba Jan 18 '15 at 20:37
  • Did you `commit` the written documents to the index? Also check for an issue in your application logic. – Jacob Budin Jan 18 '15 at 20:39
  • Yes I committed those documents. I will check. Thanks. Accepting this answer since earlier I wasn't getting any result at all. – blackmamba Jan 18 '15 at 21:07