IndexReader indexReader = IndexReader.open(directory); // this one uses default readonly mode
use this instead:
IndexReader indexReader = IndexReader.open(directory, false);
Therefore, you do not need an additional tool to remove the contents of the index.,.
source
share