2.2. Indexing Modes
2.2.1. Managing Indexes
In Red Hat JBoss Data Grid's Query Module there are two options for storing indexes:
- Each node can maintain an individual copy of the global index.
- The index can be shared across all nodes.
When the indexes are stored locally, each write to cache must be forwarded to all other nodes so that they can update their indexes. If the index is shared, only the node where the write originates is required to update the shared index.
Lucene provides an abstraction of the directory structure called
directory provider, which is used to store the index. The index can be stored, for example, as in-memory, on filesystem, or in distributed cache.
2.2.2. Managing the Index in Local Mode
In local mode, any Lucene Directory implementation may be used. The
indexLocalOnlyoption is meaningless in local mode.
2.2.3. Managing the Index in Replicated Mode
In replication mode, each node can store its own local copy of the index. To store indexes locally on each node, set
false, so that each node will apply the required updates it receives from other nodes in addition to the updates started locally.
Any Directory implementation can be used. When a new node is started it must receive an up to date copy of the index. Usually this can be done via resync, however being an external operation, this may result in a slightly out of sync index, particularly where updates are frequent.
Alternatively, if a shared storage for indexes is used (see Section 2.3.3, “Infinispan Directory Provider”),
indexLocalOnlymust be set to
trueso that each node will only apply the changes originated locally. While there is no risk of having an out of sync index, this avoids write contention on the index where a single node is being used to update the index.
The following diagram demonstrates a replicated deployment where each node has a local index.
Figure 2.1. Replicated Cache Querying
2.2.4. Managing the Index in Distribution Mode
In both Distribution modes, the shared index must be used, with the
The following diagram shows a deployment with a shared index.
Figure 2.2. Querying with a Shared Index
2.2.5. Managing the Index in Invalidation Mode
Indexing and searching of elements in Invalidation mode is not supported.