Interface IndexLayoutStrategy


public interface IndexLayoutStrategy
Defines the layout of indexes on the Elasticsearch side: the name of aliases to assign to Elasticsearch indexes, as well as the structure of non-alias names.
  • Method Details

    • createInitialElasticsearchIndexName

      String createInitialElasticsearchIndexName(String hibernateSearchIndexName)
      Generates an initial non-alias Elasticsearch name for an index.

      When createReadAlias(String) or createWriteAlias(String) returns null, this must consistently return the same value for each index, even across multiple executions of the application. Otherwise, the only requirement is that returned names are unique.

      Parameters:
      hibernateSearchIndexName - The Hibernate Search name of an index.
      Returns:
      The non-alias Elasticsearch name for this index.
    • createWriteAlias

      String createWriteAlias(String hibernateSearchIndexName)
      Generates the write alias for an index.

      This alias will be used when indexing documents, purging the index, ...

      This must consistently return the same value for each index, even across multiple executions of the application.

      If you do not want to use aliases for write operations, return null: the non-alias name returned by createInitialElasticsearchIndexName(String) will be used instead.

      Parameters:
      hibernateSearchIndexName - The Hibernate Search name of an index.
      Returns:
      The write alias for this index.
    • createReadAlias

      String createReadAlias(String hibernateSearchIndexName)
      Generates the read alias for an index.

      This alias will be used when executing search queries.

      This must consistently return the same value for each index, even across multiple executions of the application.

      If you do not want to use aliases for read operations, return null: the non-alias name returned by createInitialElasticsearchIndexName(String) will be used instead.

      Parameters:
      hibernateSearchIndexName - The Hibernate Search name of an index.
      Returns:
      The read alias for this index.
    • extractUniqueKeyFromHibernateSearchIndexName

      default String extractUniqueKeyFromHibernateSearchIndexName(String hibernateSearchIndexName)
      Extracts a unique key from a Hibernate Search index name.

      Optional operation: this method only has to be implemented when using the index-name type-name mapping strategy.

      This method will be called once per index on bootstrap.

      The returned key must be consistent with the key returned by extractUniqueKeyFromElasticsearchIndexName(String).

      Parameters:
      hibernateSearchIndexName - The Hibernate Search name of an index.
      Returns:
      The unique key assigned to that index.
    • extractUniqueKeyFromElasticsearchIndexName

      default String extractUniqueKeyFromElasticsearchIndexName(String elasticsearchIndexName)
      Extracts a unique key from a (non-alias) Elasticsearch index name.

      Optional operation: this method only has to be implemented when using the index-name type-name mapping strategy.

      This method will be called once per index on bootstrap.

      The returned key must be consistent with the key returned by extractUniqueKeyFromHibernateSearchIndexName(String).

      Parameters:
      elasticsearchIndexName - A primary index name extracted from an Elasticsearch response.
      Returns:
      The unique key assigned to that index.