Class HibernateOrmMassIndexer

    • Method Detail

      • transactionTimeout

        public MassIndexer transactionTimeout​(int timeoutInSeconds)
        Description copied from interface: MassIndexer
        Timeout of transactions for loading ids and entities to be re-indexed.

        Specify a timeout which is long enough to load and index all entities of the type with the most instances, taking into account the configured batch size and number of threads to load objects.

        Only supported in JTA-compatible environments.

        Specified by:
        transactionTimeout in interface MassIndexer
        Parameters:
        timeoutInSeconds - the transaction timeout in seconds; If no value is given, the global default timeout of the JTA environment applies.
        Returns:
        this for method chaining
      • cacheMode

        public MassIndexer cacheMode​(org.hibernate.CacheMode cacheMode)
        Description copied from interface: MassIndexer
        Sets the cache interaction mode for the data loading tasks.

        Defaults to CacheMode.IGNORE.

        Specified by:
        cacheMode in interface MassIndexer
        Parameters:
        cacheMode - the cache interaction mode
        Returns:
        this for method chaining
      • type

        public MassIndexerFilteringTypeStep type​(Class<?> type)
        Description copied from interface: MassIndexer
        Define a filter on a given type for entities to be re-indexed
        Specified by:
        type in interface MassIndexer
        Parameters:
        type - The type on which the filter will be applied
        Returns:
        The step allowing to define the filter
      • typesToIndexInParallel

        public MassIndexer typesToIndexInParallel​(int threadsToIndexObjects)
        Description copied from interface: MassIndexer
        Sets the number of entity types to be indexed in parallel.

        Defaults to 1.

        Specified by:
        typesToIndexInParallel in interface MassIndexer
        Parameters:
        threadsToIndexObjects - number of entity types to be indexed in parallel
        Returns:
        this for method chaining
      • threadsToLoadObjects

        public MassIndexer threadsToLoadObjects​(int numberOfThreads)
        Description copied from interface: MassIndexer
        Sets the number of threads to be used to load the root entities.
        Specified by:
        threadsToLoadObjects in interface MassIndexer
        Parameters:
        numberOfThreads - the number of threads
        Returns:
        this for method chaining
      • batchSizeToLoadObjects

        public HibernateOrmMassIndexer batchSizeToLoadObjects​(int batchSize)
        Description copied from interface: MassIndexer
        Sets the batch size used to load the root entities.
        Specified by:
        batchSizeToLoadObjects in interface MassIndexer
        Parameters:
        batchSize - the batch size
        Returns:
        this for method chaining
      • mergeSegmentsOnFinish

        public MassIndexer mergeSegmentsOnFinish​(boolean enable)
        Description copied from interface: MassIndexer
        Merges each index into a single segment after indexing.

        Defaults to false.

        Specified by:
        mergeSegmentsOnFinish in interface MassIndexer
        Parameters:
        enable - true to enable this operation, false to disable it.
        Returns:
        this for method chaining
      • mergeSegmentsAfterPurge

        public MassIndexer mergeSegmentsAfterPurge​(boolean enable)
        Description copied from interface: MassIndexer
        Merges each index into a single segment after the initial index purge, just before indexing.

        Defaults to true.

        This setting has no effect if purgeAllOnStart is set to false.

        Specified by:
        mergeSegmentsAfterPurge in interface MassIndexer
        Parameters:
        enable - true to enable this operation, false to disable it.
        Returns:
        this for method chaining
      • dropAndCreateSchemaOnStart

        public MassIndexer dropAndCreateSchemaOnStart​(boolean dropAndCreateSchema)
        Description copied from interface: MassIndexer
        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 (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 purge on large indexes.

        Defaults to false.

        Specified by:
        dropAndCreateSchemaOnStart in interface MassIndexer
        Parameters:
        dropAndCreateSchema - if true the indexes and their schema will be dropped then re-created before starting the indexing
        Returns:
        this for method chaining
      • purgeAllOnStart

        public MassIndexer purgeAllOnStart​(boolean purgeAll)
        Description copied from interface: MassIndexer
        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.

        Specified by:
        purgeAllOnStart in interface MassIndexer
        Parameters:
        purgeAll - if true all entities will be removed from the indexes before starting the indexing
        Returns:
        this for method chaining
      • limitIndexedObjectsTo

        public HibernateOrmMassIndexer limitIndexedObjectsTo​(long maximum)
        Description copied from interface: MassIndexer
        Stops indexing after having indexed a set amount of objects.

        As a results the indexes will not be consistent with the database: use only for testing on an (undefined) subset of database data.

        Specified by:
        limitIndexedObjectsTo in interface MassIndexer
        Parameters:
        maximum - the maximum number of objects to index
        Returns:
        this for method chaining
      • idFetchSize

        public HibernateOrmMassIndexer idFetchSize​(int idFetchSize)
        Description copied from interface: MassIndexer
        Specifies the fetch size to be used when loading primary keys if objects to be indexed.

        Some databases accept special values, for example MySQL might benefit from using Integer.MIN_VALUE otherwise it will attempt to preload everything in memory.

        Specified by:
        idFetchSize in interface MassIndexer
        Parameters:
        idFetchSize - the fetch size to be used when loading primary keys
        Returns:
        this for method chaining
      • failureFloodingThreshold

        public MassIndexer failureFloodingThreshold​(long threshold)
        Description copied from interface: MassIndexer
        Sets the threshold for failures that will be reported and sent to MassIndexingFailureHandler per 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:
        failureFloodingThreshold in interface MassIndexer
        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 the threshold defined by the failure handler itself.

        Defaults to 100 with the default failure handler.

        Returns:
        this for method chaining