Hi,
We're writing a web application, which naturally needs
- "IndexSearcher" when users use our search screen
- "IndexWriter" in a background process that periodically updates and optimizes
our index.
Note our writer is exclusive - no other applications/threads ever write to our
index files.
What's the common practice in terms of resource creation and sharing?
Specifically:
1) Should I have a single IndexSearcher to serve all (concurrent) users?
I saw such a recommendation in a tutorial, but discovered that an open
IndexSearcher prevents 'optimize' from merging my files... so should I close it
just before optimization? Or should I open an individual (short-lived)
IndexSearcher for each search request?
2) Our tests also imply that IndexWriter.optimize() takes effect only after
you close() that writer - which is a shame, because I hoped to keep using the
same writer (I hear it's expensive to instantiate). I doing something wrong?
Thanks