org.hibernate.search
Interface MassIndexer

All Known Implementing Classes:
MassIndexerImpl

public interface MassIndexer

A MassIndexer is useful to rebuild the indexes from the data contained in the database. This process is expensive: all indexed entities and their indexedEmbedded properties are scrolled from database.

Author:
Sanne Grinovero

Method Summary
 MassIndexer batchSizeToLoadObjects(int batchSize)
          Sets the batch size used to load the root entities.
 MassIndexer cacheMode(CacheMode cacheMode)
          Sets the cache interaction mode for the data loading tasks.
 MassIndexer idFetchSize(int idFetchSize)
          Specifies the fetch size to be used when loading primary keys if objects to be indexed.
 MassIndexer limitIndexedObjectsTo(long maximum)
          EXPERIMENTAL method: will probably change Will stop indexing after having indexed a set amount of objects.
 MassIndexer optimizeAfterPurge(boolean optimize)
          If index optimization should be run before starting, after the purgeAll.
 MassIndexer optimizeOnFinish(boolean optimize)
          If index optimization has to be started at the end of the indexing process.
 MassIndexer progressMonitor(MassIndexerProgressMonitor monitor)
          Override the default MassIndexerProgressMonitor.
 MassIndexer purgeAllOnStart(boolean purgeAll)
          If all entities should be removed from the index before starting using purgeAll.
 Future<?> start()
          Starts the indexing process in background (asynchronous).
 void startAndWait()
          Starts the indexing process, and then block until it's finished.
 MassIndexer threadsForIndexWriter(int numberOfThreads)
          Deprecated. 
 MassIndexer threadsForSubsequentFetching(int numberOfThreads)
          Sets the number of threads used to load the lazy collections related to the indexed entities.
 MassIndexer threadsToLoadObjects(int numberOfThreads)
          Set the number of threads to be used to load the root entities.
 

Method Detail

threadsToLoadObjects

MassIndexer threadsToLoadObjects(int numberOfThreads)
Set the number of threads to be used to load the root entities.

Parameters:
numberOfThreads -
Returns:
this for method chaining

batchSizeToLoadObjects

MassIndexer batchSizeToLoadObjects(int batchSize)
Sets the batch size used to load the root entities.

Parameters:
batchSize -
Returns:
this for method chaining

threadsForSubsequentFetching

MassIndexer threadsForSubsequentFetching(int numberOfThreads)
Sets the number of threads used to load the lazy collections related to the indexed entities.

Parameters:
numberOfThreads -
Returns:
this for method chaining

threadsForIndexWriter

@Deprecated
MassIndexer threadsForIndexWriter(int numberOfThreads)
Deprecated. 

Deprecated: value is ignored. To have more threads working on the IndexWriter, use the worker.thread_pool.size option.


progressMonitor

MassIndexer progressMonitor(MassIndexerProgressMonitor monitor)
Override the default MassIndexerProgressMonitor.

Parameters:
monitor - this instance will receive updates about the massindexing progress.
Returns:
this for method chaining

cacheMode

MassIndexer cacheMode(CacheMode cacheMode)
Sets the cache interaction mode for the data loading tasks. Defaults to CacheMode.IGNORE.

Returns:
this for method chaining

optimizeOnFinish

MassIndexer optimizeOnFinish(boolean optimize)
If index optimization has to be started at the end of the indexing process. Defaults to true.

Parameters:
optimize -
Returns:
this for method chaining

optimizeAfterPurge

MassIndexer optimizeAfterPurge(boolean optimize)
If index optimization should be run before starting, after the purgeAll. Has no effect if purgeAll is set to false. Defaults to true.

Parameters:
optimize -
Returns:
this for method chaining

purgeAllOnStart

MassIndexer purgeAllOnStart(boolean purgeAll)
If all entities should be removed from the index before starting using purgeAll. Set it to false only if you know there are no entities in the index: otherwise search results may be duplicated. Defaults to true.

Parameters:
purgeAll -
Returns:
this for method chaining

limitIndexedObjectsTo

MassIndexer limitIndexedObjectsTo(long maximum)
EXPERIMENTAL method: will probably change Will stop indexing after having indexed a set amount of objects. As a results the index will not be consistent with the database: use only for testing on an (undefined) subset of database data.

Parameters:
maximum -
Returns:
this for method chaining

start

Future<?> start()
Starts the indexing process in background (asynchronous). Can be called only once.

Returns:
a Future to control task canceling. get() will block until completion. cancel() is currently not implemented.

startAndWait

void startAndWait()
                  throws InterruptedException
Starts the indexing process, and then block until it's finished. Can be called only once.

Throws:
InterruptedException - if the current thread is interrupted while waiting.

idFetchSize

MassIndexer idFetchSize(int idFetchSize)
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.

Parameters:
idFetchSize -
Returns:
this for method chaining


Copyright © 2006-2012 Red Hat Middleware, LLC. All Rights Reserved