diff --git a/.gitignore b/.gitignore index 01d6fe8..e8b8f48 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ target/ -.vscode \ No newline at end of file +.vscode +nbactions.xml \ No newline at end of file diff --git a/adapters/lucene/src/main/java/com/github/thmarx/mongo/search/adapters/lucene/LuceneIndexAdapter.java b/adapters/lucene/src/main/java/com/github/thmarx/mongo/search/adapters/lucene/LuceneIndexAdapter.java index 3bc5214..fb1477d 100644 --- a/adapters/lucene/src/main/java/com/github/thmarx/mongo/search/adapters/lucene/LuceneIndexAdapter.java +++ b/adapters/lucene/src/main/java/com/github/thmarx/mongo/search/adapters/lucene/LuceneIndexAdapter.java @@ -37,6 +37,7 @@ import java.util.concurrent.Executors; import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.TimeUnit; +import lombok.extern.slf4j.Slf4j; import org.apache.lucene.index.Term; import org.apache.lucene.search.BooleanClause; import org.apache.lucene.search.BooleanQuery; @@ -48,6 +49,7 @@ * * @author t.marx */ +@Slf4j public class LuceneIndexAdapter extends AbstractIndexAdapter { LuceneIndex luceneIndex; @@ -101,6 +103,7 @@ public LuceneIndex getIndex() { @Override public void close() throws Exception { + log.debug("close lucene index adapter"); scheduler.shutdown(); queueWorker.stop(); queueWorkerThread.interrupt(); @@ -123,8 +126,14 @@ public void open() throws IOException { luceneIndex.open(); scheduler.scheduleWithFixedDelay(() -> { - luceneIndex.commit(); - }, 1, 1, TimeUnit.SECONDS); + try { + log.debug("commit index"); + luceneIndex.commit(); + log.debug("commited"); + } catch (Exception e) { + log.error("", e); + } + }, 1, 10, TimeUnit.SECONDS); queueWorker = new PausableThread(true) { @Override diff --git a/adapters/lucene/src/main/java/com/github/thmarx/mongo/search/adapters/lucene/index/LuceneIndex.java b/adapters/lucene/src/main/java/com/github/thmarx/mongo/search/adapters/lucene/index/LuceneIndex.java index 6d0b639..4794a0f 100644 --- a/adapters/lucene/src/main/java/com/github/thmarx/mongo/search/adapters/lucene/index/LuceneIndex.java +++ b/adapters/lucene/src/main/java/com/github/thmarx/mongo/search/adapters/lucene/index/LuceneIndex.java @@ -23,6 +23,7 @@ import java.io.IOException; import java.util.logging.Level; import java.util.logging.Logger; +import lombok.extern.slf4j.Slf4j; import org.apache.lucene.document.Document; import org.apache.lucene.facet.FacetsConfig; import org.apache.lucene.index.IndexWriter; @@ -40,6 +41,7 @@ * * @author t.marx */ +@Slf4j public class LuceneIndex { private IndexWriter writer; @@ -87,10 +89,9 @@ public void deleteDocuments (Query query) throws IOException { public void commit() { try { writer.commit(); - writer.maybeMerge(); searcherManager.maybeRefresh(); } catch (IOException ex) { - Logger.getLogger(LuceneIndex.class.getName()).log(Level.SEVERE, null, ex); + log.error("", ex); } } diff --git a/core/src/main/java/com/github/thmarx/mongo/search/index/MongoSearch.java b/core/src/main/java/com/github/thmarx/mongo/search/index/MongoSearch.java index ed8e271..1bbd7a7 100644 --- a/core/src/main/java/com/github/thmarx/mongo/search/index/MongoSearch.java +++ b/core/src/main/java/com/github/thmarx/mongo/search/index/MongoSearch.java @@ -32,7 +32,6 @@ import com.github.thmarx.mongo.search.adapter.IndexAdapter; import com.github.thmarx.mongo.search.index.commands.Command; -import com.github.thmarx.mongo.search.index.indexer.Initializer; import com.github.thmarx.mongo.search.index.indexer.Updater; import com.github.thmarx.mongo.trigger.CollectionTrigger; import com.github.thmarx.mongo.trigger.DatabaseTrigger; diff --git a/core/src/main/java/com/github/thmarx/mongo/search/index/commands/InitializeCommand.java b/core/src/main/java/com/github/thmarx/mongo/search/index/commands/InitializeCommand.java index 3541d89..202d989 100644 --- a/core/src/main/java/com/github/thmarx/mongo/search/index/commands/InitializeCommand.java +++ b/core/src/main/java/com/github/thmarx/mongo/search/index/commands/InitializeCommand.java @@ -56,6 +56,7 @@ public void execute(final IndexAdapter indexAdapter, final MongoDatabase databas log.error("error clearing collection", e); } log.debug("index collection " + collection); + log.debug(dbCol.countDocuments() + " documents to index"); dbCol.find(Filters.empty()).forEach((document) -> { try { indexAdapter.indexDocument(database.getName(), collection, document); @@ -63,7 +64,7 @@ public void execute(final IndexAdapter indexAdapter, final MongoDatabase databas log.error("error indexing document", e); } }); - + log.debug("collection indexed"); } });