Interface PojoMassIndexer
-
public interface PojoMassIndexerA MassIndexer is useful to rebuild the indexes from the data contained in the database. This process is expensive: all indexed entities and their indexedEmbedded properties are scrolled from database.- Author:
- Sanne Grinovero
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description PojoMassIndexerdropAndCreateSchemaOnStart(boolean dropAndCreateSchema)Drops the indexes and their schema (if they exist) and re-creates them before indexing.PojoMassIndexerfailureHandler(MassIndexingFailureHandler failureHandler)Sets theMassIndexingFailureHandler.PojoMassIndexermergeSegmentsAfterPurge(boolean enable)Merges each index into a single segment after the initial index purge, just before indexing.PojoMassIndexermergeSegmentsOnFinish(boolean enable)Merges each index into a single segment after indexing.PojoMassIndexermonitor(MassIndexingMonitor monitor)Sets theMassIndexingMonitor.PojoMassIndexerpurgeAllOnStart(boolean purgeAll)Removes all entities from the indexes before indexing.CompletionStage<?>start()Starts the indexing process in background (asynchronous).voidstartAndWait()Starts the indexing process, and then block until it's finished.PojoMassIndexerthreadsToLoadObjects(int numberOfThreads)Sets the number of threads to be used to load the root entities.PojoMassIndexertypesToIndexInParallel(int threadsToIndexObjects)Sets the number of entity types to be indexed in parallel.
-
-
-
Method Detail
-
typesToIndexInParallel
PojoMassIndexer typesToIndexInParallel(int threadsToIndexObjects)
Sets the number of entity types to be indexed in parallel.Defaults to
1.- Parameters:
threadsToIndexObjects- number of entity types to be indexed in parallel- Returns:
thisfor method chaining
-
threadsToLoadObjects
PojoMassIndexer threadsToLoadObjects(int numberOfThreads)
Sets the number of threads to be used to load the root entities.- Parameters:
numberOfThreads- the number of threads- Returns:
thisfor method chaining
-
mergeSegmentsOnFinish
PojoMassIndexer mergeSegmentsOnFinish(boolean enable)
Merges each index into a single segment after indexing.Defaults to
false.- Parameters:
enable-trueto enable this operation,falseto disable it.- Returns:
thisfor method chaining
-
mergeSegmentsAfterPurge
PojoMassIndexer mergeSegmentsAfterPurge(boolean enable)
Merges each index into a single segment after the initial index purge, just before indexing.Defaults to
true.This setting has no effect if
purgeAllOnStartis set to false.- Parameters:
enable-trueto enable this operation,falseto disable it.- Returns:
thisfor method chaining
-
dropAndCreateSchemaOnStart
PojoMassIndexer dropAndCreateSchemaOnStart(boolean dropAndCreateSchema)
Drops the indexes and their schema (if they exist) and re-creates them before indexing.Indexes will be unavailable for a short time during the dropping and re-creation, so this should only be used when failures of concurrent operations on the indexes (automatic indexing, ...) are acceptable.
This should be used when the existing schema is known to be obsolete, for example when the Hibernate Search mapping changed and some fields now have a different type, a different analyzer, new capabilities (projectable, ...), etc.
This may also be used when the schema is up-to-date, since it can be faster than a
purgeon large indexes.Defaults to
false.- Parameters:
dropAndCreateSchema- iftruethe indexes and their schema will be dropped then re-created before starting the indexing- Returns:
thisfor method chaining
-
purgeAllOnStart
PojoMassIndexer purgeAllOnStart(boolean purgeAll)
Removes all entities from the indexes before indexing.Set this to false only if you know there are no entities in the indexes: otherwise search results may be duplicated.
Defaults to
true.- Parameters:
purgeAll- iftrueall entities will be removed from the indexes before starting the indexing- Returns:
thisfor method chaining
-
start
CompletionStage<?> start()
Starts the indexing process in background (asynchronous).May only be called once.
- Returns:
- a
CompletionStageto react to the completion of the indexing task. CallCompletionStage.toCompletableFuture()on the returned object to convert it to aCompletableFuture(which implementsFuture).
-
startAndWait
void startAndWait() throws InterruptedExceptionStarts the indexing process, and then block until it's finished.May only be called once.
- Throws:
InterruptedException- if the current thread is interrupted while waiting.
-
monitor
PojoMassIndexer monitor(MassIndexingMonitor monitor)
Sets theMassIndexingMonitor.The default monitor just logs the progress.
- Parameters:
monitor- The monitor that will track mass indexing progress.- Returns:
thisfor method chaining
-
failureHandler
PojoMassIndexer failureHandler(MassIndexingFailureHandler failureHandler)
Sets theMassIndexingFailureHandler.The default handler just forwards failures to the
background failure handler.- Parameters:
failureHandler- The handler for failures occurring during mass indexing.- Returns:
thisfor method chaining
-
-