Update policies

This commit is contained in:
Andrea Cavalli 2021-11-20 01:30:06 +01:00
parent 06d98040b1
commit 798b8a5288
2 changed files with 6 additions and 5 deletions

View File

@ -85,7 +85,8 @@ public interface LLLuceneIndex extends LLSnapshottable {
Mono<Void> close();
/**
* Flush writes to disk
* Flush writes to disk.
* This does not commit, it syncs the data to the disk
*/
Mono<Void> flush();

View File

@ -54,9 +54,11 @@ import org.apache.lucene.index.ConcurrentMergeScheduler;
import org.apache.lucene.index.IndexWriter;
import org.apache.lucene.index.IndexWriterConfig;
import org.apache.lucene.index.KeepOnlyLastCommitDeletionPolicy;
import org.apache.lucene.index.MergePolicy;
import org.apache.lucene.index.MergeScheduler;
import org.apache.lucene.index.SerialMergeScheduler;
import org.apache.lucene.index.SnapshotDeletionPolicy;
import org.apache.lucene.index.TieredMergePolicy;
import org.apache.lucene.misc.store.DirectIODirectory;
import org.apache.lucene.search.similarities.Similarity;
import org.apache.lucene.store.ByteBuffersDirectory;
@ -465,7 +467,7 @@ public class LLLocalLuceneIndex implements LLLuceneIndex {
.<Void>fromCallable(() -> {
if (activeTasks.isTerminated()) return null;
//noinspection BlockingMethodInNonBlockingContext
indexWriter.commit();
indexWriter.flush();
return null;
})
.subscribeOn(luceneHeavyTasksScheduler)
@ -496,9 +498,7 @@ public class LLLocalLuceneIndex implements LLLuceneIndex {
private void scheduledCommit() {
try {
if (indexWriter.hasUncommittedChanges()) {
indexWriter.commit();
}
indexWriter.commit();
} catch (IOException ex) {
logger.error(MARKER_LUCENE, "Failed to execute a scheduled commit", ex);
}