Class MassIndexingJob.ParametersBuilder
- java.lang.Object
-
- org.hibernate.search.batch.jsr352.core.massindexing.MassIndexingJob.ParametersBuilder
-
- Enclosing class:
- MassIndexingJob
public static class MassIndexingJob.ParametersBuilder extends Object
Parameter builder for mass-indexing job. The default value of each parameter is defined in the job XML filehibernate-search-mass-indexing.xml
.
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Properties
build()
Build the parameters.MassIndexingJob.ParametersBuilder
cacheMode(org.hibernate.CacheMode cacheMode)
The HibernateCacheMode
when loading entities.MassIndexingJob.ParametersBuilder
checkpointInterval(int checkpointInterval)
The number of entities to process before triggering the next checkpoint.MassIndexingJob.ParametersBuilder
entityFetchSize(int entityFetchSize)
Specifies the fetch size to be used when loading entities from database.MassIndexingJob.ParametersBuilder
entityManagerFactoryNamespace(String namespace)
The string that allows to select how you want to reference theEntityManagerFactory
.MassIndexingJob.ParametersBuilder
entityManagerFactoryReference(String reference)
The string that will identify theEntityManagerFactory
.MassIndexingJob.ParametersBuilder
idFetchSize(int idFetchSize)
Specifies the fetch size to be used when loading primary keys at the step-level.MassIndexingJob.ParametersBuilder
maxResultsPerEntity(int maxResultsPerEntity)
The maximum number of results to load per entity type.MassIndexingJob.ParametersBuilder
maxThreads(int maxThreads)
The maximum number of threads to use for processing the job.MassIndexingJob.ParametersBuilder
mergeSegmentsAfterPurge(boolean mergeSegmentsAfterPurge)
Specify whether the mass indexer should merge segments at the beginning of the job.MassIndexingJob.ParametersBuilder
mergeSegmentsOnFinish(boolean mergeSegmentsOnFinish)
Specify whether the mass indexer should merge segments at the end of the job.MassIndexingJob.ParametersBuilder
purgeAllOnStart(boolean purgeAllOnStart)
Specify whether the existing lucene index should be purged at the beginning of the job.MassIndexingJob.ParametersBuilder
restrictedBy(String hql)
Use HQL / JPQL to index entities of a target entity type.MassIndexingJob.ParametersBuilder
rowsPerPartition(int rowsPerPartition)
The maximum number of rows to process per partition.MassIndexingJob.ParametersBuilder
sessionClearInterval(int sessionClearInterval)
The number of entities to process before clearing the session.MassIndexingJob.ParametersBuilder
tenantId(String tenantId)
Define the tenant ID for the job execution.
-
-
-
Method Detail
-
entityManagerFactoryNamespace
public MassIndexingJob.ParametersBuilder entityManagerFactoryNamespace(String namespace)
The string that allows to select how you want to reference theEntityManagerFactory
. Possible values are:persistence-unit-name
(the default): use the persistence unit name defined inpersistence.xml
.session-factory-name
: use the session factory name defined in the Hibernate configuration by thehibernate.session_factory_name
configuration property.
- Parameters:
namespace
- the name of namespace to use- Returns:
- itself
-
entityManagerFactoryReference
public MassIndexingJob.ParametersBuilder entityManagerFactoryReference(String reference)
The string that will identify theEntityManagerFactory
. This method is required if there's more than one persistence unit.- Parameters:
reference
- the name of reference- Returns:
- itself
-
cacheMode
public MassIndexingJob.ParametersBuilder cacheMode(org.hibernate.CacheMode cacheMode)
The HibernateCacheMode
when loading entities.This is an optional parameter, its default value is
MassIndexingJobParameters.Defaults.CACHE_MODE
.- Parameters:
cacheMode
- the cache mode- Returns:
- itself
-
sessionClearInterval
public MassIndexingJob.ParametersBuilder sessionClearInterval(int sessionClearInterval)
The number of entities to process before clearing the session. The value defined must be greater than 0, and equal to or less than the value ofcheckpointInterval
.This is an optional parameter, its default value is
MassIndexingJobParameters.Defaults.SESSION_CLEAR_INTERVAL_DEFAULT_RAW
, or the value ofcheckpointInterval
if it is smaller.- Parameters:
sessionClearInterval
- the number of entities to process before clearing the session.- Returns:
- itself
-
checkpointInterval
public MassIndexingJob.ParametersBuilder checkpointInterval(int checkpointInterval)
The number of entities to process before triggering the next checkpoint. The value defined must be greater than 0, and equal to or less than the value ofrowsPerPartition
.This is an optional parameter, its default value is
MassIndexingJobParameters.Defaults.CHECKPOINT_INTERVAL_DEFAULT_RAW
, or the value ofrowsPerPartition
if it is smaller.- Parameters:
checkpointInterval
- the number of entities to process before triggering the next checkpoint.- Returns:
- itself
-
idFetchSize
public MassIndexingJob.ParametersBuilder idFetchSize(int idFetchSize)
Specifies the fetch size to be used when loading primary keys at the step-level. Some databases accept special values, for example MySQL might benefit from usingInteger.MIN_VALUE
, otherwise it will attempt to preload everything in memory.This is an optional parameter, its default value is
MassIndexingJobParameters.Defaults.ID_FETCH_SIZE
.- Parameters:
idFetchSize
- the fetch size to be used when loading primary keys- Returns:
- itself
-
entityFetchSize
public MassIndexingJob.ParametersBuilder entityFetchSize(int entityFetchSize)
Specifies the fetch size to be used when loading entities from database. Some databases accept special values, for example MySQL might benefit from usingInteger.MIN_VALUE
, otherwise it will attempt to preload everything in memory.This is an optional parameter, its default value is the value of the session clear interval.
- Parameters:
entityFetchSize
- the fetch size to be used when loading entities- Returns:
- itself
-
maxResultsPerEntity
public MassIndexingJob.ParametersBuilder maxResultsPerEntity(int maxResultsPerEntity)
The maximum number of results to load per entity type. This parameter let you define a threshold value to avoid loading too many entities accidentally. The value defined must be greater than 0. The parameter is not used by default. It is equivalent to keyword LIMIT in SQL.- Parameters:
maxResultsPerEntity
- the maximum number of results returned per entity type.- Returns:
- itself
-
maxThreads
public MassIndexingJob.ParametersBuilder maxThreads(int maxThreads)
The maximum number of threads to use for processing the job. Note the batch runtime cannot guarantee the request number of threads are available; it will use as many as it can up to the request maximum.This is an optional parameter, its default value is the number of partitions.
- Parameters:
maxThreads
- the maximum number of threads.- Returns:
- itself
-
mergeSegmentsAfterPurge
public MassIndexingJob.ParametersBuilder mergeSegmentsAfterPurge(boolean mergeSegmentsAfterPurge)
Specify whether the mass indexer should merge segments at the beginning of the job. This operation takes place after the purge operation and before indexing.This is an optional parameter, its default value is
MassIndexingJobParameters.Defaults.MERGE_SEGMENTS_AFTER_PURGE
.- Parameters:
mergeSegmentsAfterPurge
- merge segments after purge.- Returns:
- itself
-
mergeSegmentsOnFinish
public MassIndexingJob.ParametersBuilder mergeSegmentsOnFinish(boolean mergeSegmentsOnFinish)
Specify whether the mass indexer should merge segments at the end of the job. This operation takes place after indexing.This is an optional parameter, its default value is
MassIndexingJobParameters.Defaults.MERGE_SEGMENTS_ON_FINISH
.- Parameters:
mergeSegmentsOnFinish
- merge segments on finish.- Returns:
- itself
-
purgeAllOnStart
public MassIndexingJob.ParametersBuilder purgeAllOnStart(boolean purgeAllOnStart)
Specify whether the existing lucene index should be purged at the beginning of the job. This operation takes place before indexing.This is an optional parameter, its default value is
MassIndexingJobParameters.Defaults.PURGE_ALL_ON_START
.- Parameters:
purgeAllOnStart
- purge all on start.- Returns:
- itself
-
restrictedBy
public MassIndexingJob.ParametersBuilder restrictedBy(String hql)
Use HQL / JPQL to index entities of a target entity type. Your query should contain only one entity type. Mixing this approach with the criteria restriction is not allowed. Please notice that there's no query validation for your input.- Parameters:
hql
- HQL / JPQL.- Returns:
- itself
-
rowsPerPartition
public MassIndexingJob.ParametersBuilder rowsPerPartition(int rowsPerPartition)
The maximum number of rows to process per partition. The value defined must be greater than 0, and greater than the value ofcheckpointInterval
.This is an optional parameter, its default value is
MassIndexingJobParameters.Defaults.ROWS_PER_PARTITION
.- Parameters:
rowsPerPartition
- Rows per partition.- Returns:
- itself
-
tenantId
public MassIndexingJob.ParametersBuilder tenantId(String tenantId)
Define the tenant ID for the job execution.- Parameters:
tenantId
- Tenant ID. Null or empty value is not allowed.- Returns:
- itself
-
build
public Properties build()
Build the parameters.- Returns:
- the parameters.
- Throws:
SearchException
- if the serialization of some parameters fail.
-
-