Class LuceneIndexSettings


  • public final class LuceneIndexSettings
    extends Object
    Configuration properties for Lucene indexes.

    Constants in this class are to be appended to a prefix to form a property key; see IndexSettings for details.

    • Field Detail

      • DIRECTORY_PREFIX

        public static final String DIRECTORY_PREFIX
        The prefix for directory-related property keys.
        See Also:
        Constant Field Values
      • DIRECTORY_ROOT

        public static final String DIRECTORY_ROOT
        The filesystem root the directory.

        Only available for the "local-filesystem" directory type.

        Expects a String representing a path to an existing directory accessible in read and write mode, such as "local-filesystem".

        The actual index files will be created in directory <root>/<index name>.

        Defaults to the JVM's working directory (LuceneIndexSettings.Defaults.DIRECTORY_ROOT).

        See Also:
        Constant Field Values
      • DIRECTORY_LOCKING_STRATEGY

        public static final String DIRECTORY_LOCKING_STRATEGY
        The locking strategy the directory.

        Expects a LockingStrategyName value, or a String representation of such value.

        Defaults are specific to each directory type.

        See Also:
        Constant Field Values
      • IO_COMMIT_INTERVAL

        public static final String IO_COMMIT_INTERVAL
        How much time may pass after an index change until the change is committed.

        Only available for the "near-real-time" I/O strategy.

        This effectively defines how long changes may be in an "unsafe" state, where a crash or power loss will result in data loss. For example:

        • if set to 0, changes are safe as soon as the background process finishes treating a batch of changes.
        • if set to 1000, changes may not be safe for an additional 1 second after the background process finishes treating a batch. There is a benefit, though: index changes occurring less than 1 second after another change may execute faster.

        Note that individual write operations may trigger a forced commit (for example with the "committed" and "searchable" automatic indexing synchronization strategies in the ORM mapper), in which case you will only benefit from a non-zero commit interval during intensive indexing (mass indexer, ...).

        Note that saving is not necessary to make changes visible to search queries: the two concepts are unrelated. See IO_REFRESH_INTERVAL.

        Expects a positive Integer value in milliseconds, such as 1000, or a String that can be parsed into such Integer value.

        Defaults to LuceneIndexSettings.Defaults.IO_COMMIT_INTERVAL.

        See Also:
        Constant Field Values
      • IO_REFRESH_INTERVAL

        public static final String IO_REFRESH_INTERVAL
        How much time may pass after an index write until the index reader is considered stale and re-created.

        Only available for the "near-real-time" I/O strategy.

        This effectively defines how out-of-date search query results may be. For example:

        • If set to 0, search results will always be completely in sync with the index writes.
        • If set to 1000, search results may reflect the state of the index at most 1 second ago. There is a benefit, though: in situations where the index is being frequently written to, search queries executed less than 1 second after another query may execute faster.

        Note that individual write operations may trigger a forced refresh (for example with the "searchable" automatic indexing synchronization strategy in the ORM mapper), in which case you will only benefit from a non-zero refresh interval during intensive indexing (mass indexer, ...).

        Expects a positive Integer value in milliseconds, such as 1000, or a String that can be parsed into such Integer value.

        Defaults to LuceneIndexSettings.Defaults.IO_REFRESH_INTERVAL.

        See Also:
        Constant Field Values
      • IO_WRITER_PREFIX

        public static final String IO_WRITER_PREFIX
        The prefix for property keys related to the index writer.
        See Also:
        Constant Field Values
      • IO_MERGE_PREFIX

        public static final String IO_MERGE_PREFIX
        The prefix for property keys related to merge.
        See Also:
        Constant Field Values
      • SHARDING_PREFIX

        public static final String SHARDING_PREFIX
        The prefix for sharding-related property keys.
        See Also:
        Constant Field Values
      • SHARDING_STRATEGY

        public static final String SHARDING_STRATEGY
        The sharding strategy, deciding the number of shards, their identifiers, and how to translate a routing key into a shard identifier.

        Expects a String, such as "hash". See the reference documentation for a list of available values.

        Defaults to LuceneIndexSettings.Defaults.SHARDING_STRATEGY (no sharding).

        See Also:
        Constant Field Values
      • SHARDING_NUMBER_OF_SHARDS

        public static final String SHARDING_NUMBER_OF_SHARDS
        The number of shards to create for the index, i.e. the number of "physical" indexes, each holding a part of the index data.

        Only available for the "hash" sharding strategy.

        Expects a strictly positive Integer value, such as 4, or a String that can be parsed into such Integer value.

        No default: this property must be set when using the "hash" sharding strategy.

        See Also:
        Constant Field Values
      • SHARDING_SHARD_IDENTIFIERS

        public static final String SHARDING_SHARD_IDENTIFIERS
        The list of shard identifiers to accept for the index.

        Only available for the "explicit" sharding strategy.

        Expects either a String containing multiple shard identifiers separated by commas (','), or a Collection<String> containing such shard identifiers.

        No default: this property must be set when using the "explicit" sharding strategy.

        See Also:
        Constant Field Values
      • SHARDS

        public static final String SHARDS
        The root property whose children are shards, e.g. shards.0.<some shard-scoped property> = bar or shards.1.<some shard-scoped property> = bar or shards.main.<some shard-scoped property> = bar.
        See Also:
        Constant Field Values
      • INDEXING_PREFIX

        public static final String INDEXING_PREFIX
        The prefix for indexing-related property keys.
        See Also:
        Constant Field Values
      • INDEXING_QUEUE_COUNT

        public static final String INDEXING_QUEUE_COUNT
        The number of indexing queues assigned to each index (or each shard of each index, when sharding is enabled).

        Expects a strictly positive integer value, or a string that can be parsed to such integer value.

        Defaults to LuceneIndexSettings.Defaults.INDEXING_QUEUE_COUNT.

        See the reference documentation, section "Lucene backend - Indexing", for more information about this setting and its implications.

        See Also:
        Constant Field Values
      • INDEXING_QUEUE_SIZE

        public static final String INDEXING_QUEUE_SIZE
        The size of indexing queues.

        Expects a strictly positive integer value, or a string that can be parsed to such integer value.

        Defaults to LuceneIndexSettings.Defaults.INDEXING_QUEUE_SIZE.

        See the reference documentation, section "Lucene backend - Indexing", for more information about this setting and its implications.

        See Also:
        Constant Field Values
    • Method Detail

      • shardKey

        public static String shardKey​(String shardId,
                                      String radical)
        Builds a configuration property key for the given shard of all indexes of the default backend, with the given radical.

        See constants in this class for available radicals.

        Example result: "hibernate.search.backend.shard.<shardId>.indexing.queue_count"
        Parameters:
        shardId - The identifier of the shard to configure.
        radical - The radical of the configuration property (see constants in this class).
        Returns:
        the concatenated shard settings key
      • shardKey

        public static String shardKey​(String indexName,
                                      String shardId,
                                      String radical)
        Builds a configuration property key for the given shard of the given index of the default backend, with the given radical.

        See constants in this class for available radicals.

        Example result: "hibernate.search.backends.<backendName>.indexes.<indexName>.shard.<shardId>.indexing.queue_count"
        Parameters:
        indexName - The name of the index in which the shard to configure is located.
        shardId - The identifier of the shard to configure.
        radical - The radical of the configuration property (see constants in this class).
        Returns:
        the concatenated shard settings key
      • shardKey

        public static String shardKey​(String backendName,
                                      String indexName,
                                      String shardId,
                                      String radical)
        Builds a configuration property key for the given shard of the given index of the given backend, with the given radical.

        See constants in this class for available radicals.

        Example result: "hibernate.search.backends.<backendName>.indexes.<indexName>.shard.<shardId>.indexing.queue_count"
        Parameters:
        backendName - The name of the backend in which the shard to configure is located.
        indexName - The name of the index in which the shard to configure is located.
        shardId - The identifier of the shard to configure.
        radical - The radical of the configuration property (see constants in this class).
        Returns:
        the concatenated shard settings key