I am trying to understand how Lucene should be used.
From what I have read, creating an
IndexReader is costly, so using a
Search Manager shoulg be the right choice. However, a
SearchManager should be produced by a
NRTManager(which, by the way, should replace the
IndexWriter for every add or delete operation performed). But in order to have a
NRTManager, I should first have an
IndexWriter, and here comes my problem.
The documentation says:
- an IndexWriter is thread-safe
- the constructor of this class takes a
Directoryobject, so it seems creating an instace should be costly(as in the case of an IndexReader)
all changes are buffered and flushed periodically(so they seem to encourage using a single instance)
the changes, although flushed will only be visible after
- after finished making updates(add/delete), the instance should be closed
- I also found this: http://stackoverflow.com/questions/5374419/forgot-to-close-the-lucene-indexwriter-after-adding-documents-to-the-index where it is said that not closing a writer might ruin everything
So what am I really supposed to do? Is having a single
IndexWriter instance a good idea (make only
commit and never
EDIT: What is more, if I use
NRTManager, how can I make a
commit? Is it even possible?