/** * @see ContextDAO#updateSearchIndexAsync() */ @Override public Future<?> updateSearchIndexAsync() { try { log.info("Started asynchronously updating the search index..."); return Search.getFullTextSession(sessionFactory.getCurrentSession()).createIndexer().start(); } catch (Exception e) { throw new RuntimeException("Failed to start asynchronous search index update", e); } }
/** * Regenerates all the indexed class indexes * * @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(); } } }
/** * Regenerates all the indexed class indexes * * @param async true if the reindexing will be done as a background thread * @param sess the hibernate session */ public static void reindexAll(boolean async, Session sess) { FullTextSession txtSession = Search.getFullTextSession(sess); MassIndexer massIndexer = txtSession.createIndexer(); massIndexer.purgeAllOnStart(true); try { if (!async) { massIndexer.startAndWait(); } else { massIndexer.start(); } } catch (InterruptedException e) { log.error("mass reindexing interrupted: " + e.getMessage()); } finally { txtSession.flushToIndexes(); } } }
/** * @return future */ public Future<?> reCreateIndex() { FullTextSession fullTextSession = getFullTextSession(); return fullTextSession.createIndexer().start(); }
/** * @return future */ public Future<?> reCreateIndex() { FullTextSession fullTextSession = getFullTextSession(); return fullTextSession.createIndexer().start(); }
/** * {@inheritDoc} */ @Override public void rebuildIndex() { getFullTextSession().createIndexer(Topic.class).start(); } }
@POST @Path("/reindex") public Response reindex(@QueryParam("limit") Long limit) { FullTextEntityManager fullTextEm = Search.getFullTextEntityManager( em ); MassIndexer indexer = fullTextEm.createIndexer( Page.class, User.class ) .purgeAllOnStart( true ) .typesToIndexInParallel( 2 ) .batchSizeToLoadObjects( 25 ) .idFetchSize( 150 ) .threadsToLoadObjects( 10 ) .cacheMode( CacheMode.IGNORE ); // Cache is likely to do more harm than good in our case (very few relations) if ( limit != null ) { indexer.limitIndexedObjectsTo( limit ); } indexer.start(); return Response.accepted().build(); }