if ( this.purgeAtStart ) {
//purgeAll for affected entities
Set<Class<?>> targetedClasses = searchFactoryImplementor.getIndexedTypesPolymorphic( rootEntities );
for ( Class<?> clazz : targetedClasses ) {
//needs do be in-sync work to make sure we wait for the end of it.
backend.doWorkInSync( new PurgeAllLuceneWork( clazz ) );
}
if ( this.optimizeAfterPurge ) {
backend.optimize( targetedClasses );
}
}