@ Override public void contextInitialized ( final ServletContextEvent servletContextEvent ) { logger . info ( "Rebuilding Search Index..." ) ; // Build the session factory. SessionFactory factory = createSessionFactory ( ) ; // Build the hibernate session. Session session = factory . openSession ( ) ; // Create the fulltext session. FullTextSession fullTextSession = Search . getFullTextSession ( session ) ; try { fullTextSession . createIndexer ( ) . startAndWait ( ) ; } catch ( InterruptedException e ) { logger . warn ( "Search reindex interrupted. Good luck!" ) ; logger . trace ( "Error:" , e ) ; } finally { // Close everything and release the lock file. session . close ( ) ; factory . close ( ) ; } }
Rebuild the search index during context initialization .