Class IndexNameGenerator

java.lang.Object
org.elasticsearch.common.IndexNameGenerator

public final class IndexNameGenerator extends Object
Generates valid Elasticsearch index names.
  • Field Details

    • ILLEGAL_INDEXNAME_CHARS_REGEX

      public static final Pattern ILLEGAL_INDEXNAME_CHARS_REGEX
    • MAX_GENERATED_UUID_LENGTH

      public static final int MAX_GENERATED_UUID_LENGTH
      See Also:
  • Method Details

    • generateValidIndexName

      public static String generateValidIndexName(String prefix, String indexName)
      This generates a valid unique index name by using the provided prefix, appended with a generated UUID, and the index name.
    • generateValidIndexSuffix

      public static String generateValidIndexSuffix(Supplier<String> randomGenerator)
      Generates a valid index suffix, removing any illegal characters.
      Parameters:
      randomGenerator - supplier of the initial (random) suffix
      Returns:
      a valid index suffix without any illegal characters
      Throws:
      IllegalArgumentException - if removing illegal characters resulted in an empty string
    • validateGeneratedIndexName

      @Nullable public static ActionRequestValidationException validateGeneratedIndexName(String generatedIndexName, ClusterState state)
      Validates the provided index name against the provided cluster state. This checks the index name for invalid characters and that it doesn't clash with existing indices or aliases. Returns null for valid indices.