use of org.hibernate.search.batchindexing.impl.SimpleIndexingProgressMonitor in project dwoss by gg-net.
the class SearchSingletonBean method reindexSearch.
@Schedule(hour = "2")
@Override
public void reindexSearch() {
active = true;
final SubMonitor m = monitorFactory.newSubMonitor("Recreationg Searchindex");
m.start();
try {
MassIndexer indexer = Search.getFullTextEntityManager(em).createIndexer();
indexer.progressMonitor(new SimpleIndexingProgressMonitor() {
private final AtomicLong documentsDoneCounter = new AtomicLong();
private final AtomicLong totalCounter = new AtomicLong();
private final AtomicLong entitiesLoaded = new AtomicLong();
@Override
public void entitiesLoaded(int size) {
entitiesLoaded.set(size);
}
@Override
public void addToTotalCount(long count) {
super.addToTotalCount(count);
totalCounter.addAndGet(count);
}
@Override
public void documentsAdded(long increment) {
super.documentsAdded(increment);
long current = documentsDoneCounter.addAndGet(increment);
if (current % getStatusMessagePeriod() == 0) {
m.message("Prozess " + current + "/" + totalCounter.get() + " | Entities loaded: " + entitiesLoaded.get());
}
}
});
// Values still not optimal, but the mysql db holds.
indexer.batchSizeToLoadObjects(10000).threadsToLoadObjects(3).startAndWait();
} catch (InterruptedException ex) {
LOG.error("Error on Reindex Search.", ex);
} finally {
active = false;
}
m.finish();
}
Aggregations