Class 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 Detail

      • 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
      • 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 database. 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 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
      • 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
      • 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.