Class PojoDefaultMassIndexer
- All Implemented Interfaces:
PojoMassIndexer
- Author:
- Sanne Grinovero
-
Constructor Summary
ConstructorsConstructorDescriptionPojoDefaultMassIndexer(PojoMassIndexingContext massIndexingContext, PojoMassIndexingMappingContext mappingContext, PojoMassIndexingTypeContextProvider typeContextProvider, Set<? extends PojoMassIndexingIndexedTypeContext<?>> targetedIndexedTypes, PojoScopeSchemaManager scopeSchemaManager, PojoScopeDelegate<?, ?, ?> pojoScopeDelegate) -
Method Summary
Modifier and TypeMethodDescriptiondropAndCreateSchemaOnStart(boolean enable) Drops the indexes and their schema (if they exist) and re-creates them before indexing.environment(MassIndexingEnvironment environment) Sets theMassIndexingEnvironment, which can set up an environment (thread locals, ...) in mass indexing threads.failureFloodingThreshold(long threshold) Sets the threshold for failures that will be reported and sent toMassIndexingFailureHandlerper indexed type.failureHandler(MassIndexingFailureHandler failureHandler) Sets theMassIndexingFailureHandler.mergeSegmentsAfterPurge(boolean enable) Merges each index into a single segment after the initial index purge, just before indexing.mergeSegmentsOnFinish(boolean enable) Merges each index into a single segment after indexing.monitor(MassIndexingMonitor monitor) Sets theMassIndexingMonitor.purgeAllOnStart(boolean enable) Removes all entities from the indexes before indexing.start()Starts the indexing process in background (asynchronous).voidStarts the indexing process, and then block until it's finished.threadsToLoadObjects(int numberOfThreads) Sets the number of threads to be used to load the root entities.typesToIndexInParallel(int numberOfThreads) Sets the number of entity types to be indexed in parallel.
-
Constructor Details
-
PojoDefaultMassIndexer
public PojoDefaultMassIndexer(PojoMassIndexingContext massIndexingContext, PojoMassIndexingMappingContext mappingContext, PojoMassIndexingTypeContextProvider typeContextProvider, Set<? extends PojoMassIndexingIndexedTypeContext<?>> targetedIndexedTypes, PojoScopeSchemaManager scopeSchemaManager, PojoScopeDelegate<?, ?, ?> pojoScopeDelegate)
-
-
Method Details
-
typesToIndexInParallel
Description copied from interface:PojoMassIndexerSets the number of entity types to be indexed in parallel.Defaults to
1.- Specified by:
typesToIndexInParallelin interfacePojoMassIndexer- Parameters:
numberOfThreads- number of entity types to be indexed in parallel- Returns:
thisfor method chaining
-
threadsToLoadObjects
Description copied from interface:PojoMassIndexerSets the number of threads to be used to load the root entities.- Specified by:
threadsToLoadObjectsin interfacePojoMassIndexer- Parameters:
numberOfThreads- the number of threads- Returns:
thisfor method chaining
-
mergeSegmentsOnFinish
Description copied from interface:PojoMassIndexerMerges each index into a single segment after indexing.Defaults to
false.- Specified by:
mergeSegmentsOnFinishin interfacePojoMassIndexer- Parameters:
enable-trueto enable this operation,falseto disable it.- Returns:
thisfor method chaining
-
mergeSegmentsAfterPurge
Description copied from interface:PojoMassIndexerMerges 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.- Specified by:
mergeSegmentsAfterPurgein interfacePojoMassIndexer- Parameters:
enable-trueto enable this operation,falseto disable it.- Returns:
thisfor method chaining
-
dropAndCreateSchemaOnStart
Description copied from interface:PojoMassIndexerDrops 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 (indexing caused by entity changes, ...) 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.- Specified by:
dropAndCreateSchemaOnStartin interfacePojoMassIndexer- Parameters:
enable- iftruethe indexes and their schema will be dropped then re-created before starting the indexing- Returns:
thisfor method chaining
-
purgeAllOnStart
Description copied from interface:PojoMassIndexerRemoves 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.
Default value depends on
PojoMassIndexer.dropAndCreateSchemaOnStart(boolean). Defaults tofalseif the mass indexer is configured to drop and create the schema on start, totrueotherwise.- Specified by:
purgeAllOnStartin interfacePojoMassIndexer- Parameters:
enable- iftrueall entities will be removed from the indexes before starting the indexing- Returns:
thisfor method chaining
-
monitor
Description copied from interface:PojoMassIndexerSets theMassIndexingMonitor.The default monitor just logs the progress.
- Specified by:
monitorin interfacePojoMassIndexer- Parameters:
monitor- The monitor that will track mass indexing progress.- Returns:
thisfor method chaining
-
start
Description copied from interface:PojoMassIndexerStarts the indexing process in background (asynchronous).May only be called once.
- Specified by:
startin interfacePojoMassIndexer- 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
Description copied from interface:PojoMassIndexerStarts the indexing process, and then block until it's finished.May only be called once.
- Specified by:
startAndWaitin interfacePojoMassIndexer- Throws:
InterruptedException- if the current thread is interrupted while waiting.
-
failureHandler
Description copied from interface:PojoMassIndexerSets theMassIndexingFailureHandler.The default handler just forwards failures to the
background failure handler.- Specified by:
failureHandlerin interfacePojoMassIndexer- Parameters:
failureHandler- The handler for failures occurring during mass indexing.- Returns:
thisfor method chaining
-
environment
Description copied from interface:PojoMassIndexerSets theMassIndexingEnvironment, which can set up an environment (thread locals, ...) in mass indexing threads.- Specified by:
environmentin interfacePojoMassIndexer- Parameters:
environment- a component that gets a chance to set up e.g.ThreadLocalsin mass indexing threads before mass indexing starts, and to remove them after mass indexing stops.- See Also:
-
failureFloodingThreshold
Description copied from interface:PojoMassIndexerSets the threshold for failures that will be reported and sent toMassIndexingFailureHandlerper indexed type. Any failures exceeding this number will be ignored. A count of such ignored failures together with the operation they belong to will be reported to the failure handler upon the completion of indexing process.- Specified by:
failureFloodingThresholdin interfacePojoMassIndexer- Parameters:
threshold- The number of failures during one mass indexing beyond which the failure handler will no longer be notified. This threshold is reached separately for each indexed type. Overrides thethreshold defined by the failure handler itself.Defaults to
100with the default failure handler.- Returns:
thisfor method chaining
-