Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
import org.apache.lucene.index.IndexReader;
import org.apache.lucene.index.IndexWriter;
import org.apache.lucene.index.IndexWriterConfig;
import org.apache.lucene.index.NoMergeScheduler;
import org.apache.lucene.search.IndexSearcher;
import org.apache.lucene.store.Directory;
import org.apache.lucene.store.FSDirectory;
Expand Down Expand Up @@ -131,6 +132,15 @@ public LuceneTextIndexCreator(String column, File segmentIndexDir, boolean commi
indexWriterConfig.setCommitOnClose(commit);
indexWriterConfig.setUseCompoundFile(config.isLuceneUseCompoundFile());

// For the realtime segment, prevent background merging. The realtime segment will call .commit()
// on the IndexWriter when segment conversion occurs. By default, Lucene will sometimes choose to
// merge segments in the background, which is problematic because the lucene index directory's
// contents is copied to create the immutable segment. If a background merge occurs during this
// copy, a FileNotFoundException will be triggered and segment build will fail.
if (!_commitOnClose) {
indexWriterConfig.setMergeScheduler(NoMergeScheduler.INSTANCE);
}

if (_reuseMutableIndex) {
LOGGER.info("Reusing the realtime lucene index for segment {} and column {}", segmentIndexDir, column);
indexWriterConfig.setOpenMode(IndexWriterConfig.OpenMode.CREATE_OR_APPEND);
Expand Down