Class MassIndexingJob.ParametersBuilder

java.lang.Object
org.hibernate.search.jakarta.batch.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 file hibernate-search-mass-indexing.xml.
  • Method Details

    • entityManagerFactoryNamespace

      public MassIndexingJob.ParametersBuilder entityManagerFactoryNamespace(String namespace)
      The string that allows to select how you want to reference the EntityManagerFactory. Possible values are:
      • persistence-unit-name (the default): use the persistence unit name defined in persistence.xml.
      • session-factory-name: use the session factory name defined in the Hibernate configuration by the hibernate.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 the EntityManagerFactory. 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(CacheMode cacheMode)
      The Hibernate CacheMode when loading entities.

      This is an optional parameter, its default value is MassIndexingJobParameters.Defaults.CACHE_MODE.

      Parameters:
      cacheMode - the cache mode
      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 of rowsPerPartition.

      This is an optional parameter, its default value is MassIndexingJobParameters.Defaults.CHECKPOINT_INTERVAL_DEFAULT_RAW, or the value of rowsPerPartition 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 using Integer.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 the database.

      The value defined must be greater than 0, and equal to or less than the value of checkpointInterval.

      This is an optional parameter, its default value is MassIndexingJobParameters.Defaults.ENTITY_FETCH_SIZE_RAW, or the value of checkpointInterval if it is smaller.

      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
    • reindexOnly

      public MassIndexingJob.ParametersBuilder reindexOnly(String hql, Map<String,?> parameters)
      Use a JPQL/HQL conditional expression to limit the entities to be re-indexed.

      The letter e is supposed to be used here as query alias. For instance a valid expression could be the following:

           manager.level < 2
       
      ... to filter instances that have a manager whose level is strictly less than 2.

      Parameters can be used, so assuming the parameter "max" is defined in the parameters Map, this is valid as well:

           manager.level < :max
       
      ... to filter instances that have a manager whose level is strictly less than :max.
      Parameters:
      hql - A JPQL/HQL conditional expression, e.g. manager.level < 2
      parameters - A map of named parameters parameters that may be used in the conditional expression with the usual JPQL/HQL colon-prefixed syntax (e.g. ":myparam").
      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 of checkpointInterval.

      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.