* @param async true if the reindexing will be done as a background thread
* @param entityManager the entity manager
*/
public static void reindexAll(boolean async, EntityManager entityManager) {
FullTextEntityManager txtentityManager = Search.getFullTextEntityManager(entityManager);
MassIndexer massIndexer = txtentityManager.createIndexer();
massIndexer.purgeAllOnStart(true);
try {
if (!async) {
massIndexer.startAndWait();
} else {
massIndexer.start();
}
} catch (InterruptedException e) {
log.error("mass reindexing interrupted: " + e.getMessage());
} finally {
txtentityManager.flushToIndexes();