Hello all,
I have a simple question regarding the rebuild of the index with hibernate search.
I know that there is two way to rebuild the index, but I've choosen to use
flushToIndexes() as follow:
Code:
fullTextSession.setFlushMode(FlushMode.MANUAL);
fullTextSession.setCacheMode(CacheMode.IGNORE);
transaction = fullTextSession.beginTransaction();
//Scrollable results will avoid loading too many objects in memory
ScrollableResults results = fullTextSession.createCriteria( Email.class )
.setFetchSize(BATCH_SIZE)
.scroll( ScrollMode.FORWARD_ONLY );
int index = 0;
while( results.next() ) {
index++;
fullTextSession.index( results.get(0) ); //index each element
if (index % BATCH_SIZE == 0) {
fullTextSession.flushToIndexes(); //apply changes to indexes
fullTextSession.clear(); //free memory since the queue is processed
}
}
transaction.commit();
I would like to know if I can do a kind of batch with this process and being sure that gives no problem if users are still using the application during the index rebuild.
Thank you very much and happy new year ;-)