5.2. Configuring the IndexManager
The index manager component is discussed in detail in Section 4.1, “Overview” Hibernate Search offers two implementations for this interface:
directory-based: the default implementation which uses the LuceneDirectoryabstraction to manage index files.near-real-time: avoids flushing writes to disk at each commit. This index manager is alsoDirectorybased, but uses Lucene's NRT functionality.
To select an alternative, specify the following property:
hibernate.search.[default|<indexname>].indexmanager = near-real-time
5.2.1. Directory-based
The
Directory-based implementation is the default IndexManager implementation. It is highly configurable and allows separate configurations for the reader strategy, back ends, and directory providers. Refer Section 5.3, “Directory Configuration”, Section 5.4, “Worker Configuration” and Section 4.3.4, “Reader Strategy Configuration” for more details.
5.2.2. Near Real Time
The
NRTIndexManager is an extension of the default IndexManager and leverages the Lucene NRT (Near Real Time) feature for low latency index writes. However, it ignores configuration settings for alternative back ends other than lucene and acquires exclusive write locks on the Directory.
The
IndexWriter does not flush every change to the disk to provide low latency. Queries can read the updated states from the unflushed index writer buffers. However, this means that if the IndexWriter is killed or the application crashes, updates can be lost so the indexes must be rebuilt.
The Near Real Time configuration is recommended for non-clustered websites with limited data due to the mentioned disadvantages and because a master node can be individually configured for improved performance as well.
5.2.3. Custom
Specify a fully qualified class name for the custom implementation to set up a customized
IndexManager. Set up a no-argument constructor for the implementation as follows:
[default|<indexname>].indexmanager = my.corp.myapp.CustomIndexManager
The custom index manager implementation does not require the same components as the default implementations. For example, delegate to a remote indexing service which does not expose a
Directory interface.