static void checkValidIndexName(String indexName) {
    if (indexName.length() > MAX_INDEX_NAME_LENGTH) {
      throw new IllegalArgumentException(
          "Index name "
              + indexName
              + " cannot be longer than "
              + MAX_INDEX_NAME_LENGTH
              + " characters.");
    }
    Matcher matcher = ILLEGAL_INDEX_NAME_CHARS.matcher(indexName);
    if (matcher.find()) {
      throw new IllegalArgumentException(
          "Index name "
              + indexName
              + " is not a valid name. Character \""
              + matcher.group()
              + "\" is not allowed.");
    }
    if (indexName.charAt(0) == '-' || indexName.charAt(0) == '_' || indexName.charAt(0) == '+') {
      throw new IllegalArgumentException(
          "Index name " + indexName + " can not start with -, _ or +.");
    }
  }
@Test
  public void testCheckValidIndexNameThrowsErrorWhenNameIsTooLong() {
    assertThrows(
        IllegalArgumentException.class, () -> checkValidIndexName(StringUtils.repeat("a", 300)));
  }