--- title: "必须使用小写 – 如何解决此 Elasticsearch 异常" date: 2026-02-14 lastmod: 2026-02-14 description: "Elasticsearch 要求索引名称必须使用小写字母,本文介绍如何解决此异常" tags: ["索引命名", "大小写敏感", "异常处理"] summary: "版本: 6.8-8.9 简而言之,当 Elasticsearch 遇到字段或参数不符合其预期的小写格式时,就会发生此错误。Elasticsearch 区分大小写,某些字段(如索引名称)必须使用小写。要解决此问题,请确保所有索引名称、字段名称和其他参数都使用小写。如果您使用脚本或应用程序向 Elasticsearch 发送数据,请考虑添加一个函数,在发送之前将所有名称转换为小写。 日志上下文 # 日志 “must be lowercase” 的类名是 MetadataCreateIndexService.java。 我们从 Elasticsearch 源代码中提取了以下内容,供那些寻求深入背景信息的人参考: * Validate the name for an index against some static rules and a cluster state. */ public static void validateIndexName(String index, ClusterState state) { validateIndexOrAliasName(index, InvalidIndexNameException::new); if (index.toLowerCase(Locale.ROOT).equals(index) == false) { throw new InvalidIndexNameException(index, "must be lowercase"); } // NOTE: dot-prefixed index names are validated after template application; not here if (state." --- > **版本:** 6.8-8.9 简而言之,当 Elasticsearch 遇到字段或参数不符合其预期的小写格式时,就会发生此错误。Elasticsearch 区分大小写,某些字段(如索引名称)必须使用小写。要解决此问题,请确保所有索引名称、字段名称和其他参数都使用小写。如果您使用脚本或应用程序向 Elasticsearch 发送数据,请考虑添加一个函数,在发送之前将所有名称转换为小写。 ## 日志上下文 日志 "must be lowercase" 的类名是 [MetadataCreateIndexService.java。](https://www.geeksforgeeks.org/java-lang-class-class-java-set-1/) 我们从 Elasticsearch 源代码中提取了以下内容,供那些寻求深入背景信息的人参考: ```java * Validate the name for an index against some static rules and a cluster state. */ public static void validateIndexName(String index, ClusterState state) { validateIndexOrAliasName(index, InvalidIndexNameException::new); if (index.toLowerCase(Locale.ROOT).equals(index) == false) { throw new InvalidIndexNameException(index, "must be lowercase"); } // NOTE: dot-prefixed index names are validated after template application; not here if (state.routingTable().hasIndex(index)) { ```