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)
but:
the changes, although flushed will only be visible after
commitorclose- after finished making updates(add/delete), the instance should be closed
- I also found this: 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 close it)?
What is more, if I use NRTManager, how can I make a commit? Is it even possible?