--- title: "不能以下划线开头 - 如何解决此 Elasticsearch 异常" date: 2026-02-10 lastmod: 2026-02-10 description: "当 Elasticsearch 索引、别名或字段名以下划线('_')开头时会报此错误。Elasticsearch 保留以下划线开头的名称用于内部操作。解决方法是重命名索引、别名或字段,去除前导下划线。" tags: ["索引命名", "异常处理", "字段命名"] summary: "版本: 6.8-8.9 简要来说,当 Elasticsearch 索引、别名或字段名以一个下划线('_')开头时,会发生此错误。Elasticsearch 保留以下划线开头的名称用于内部操作。要解决此问题,请重命名索引、别名或字段,不要使用前导下划线。如果错误是由于数据中的字段名引起的,您可能需要预处理数据来重命名字段。或者,您可以在索引期间使用脚本或摄取节点来重命名字段。 日志上下文 # 日志 “must not start with ‘_’.” 的类名是 IndexNameExpressionResolver.java. 我们从 Elasticsearch 源代码中提取了以下内容,供那些寻求深入背景的人参考: // Expressions can not start with an underscore. This is reserved for APIs. If the check gets here; the API // does not exist and the path is interpreted as an expression. If the expression begins with an underscore; // throw a specific error that is different from the [[IndexNotFoundException]]; which is typically thrown // if the expression can't be found." --- > **版本:** 6.8-8.9 简要来说,当 Elasticsearch 索引、别名或字段名以一个下划线('_')开头时,会发生此错误。Elasticsearch 保留以下划线开头的名称用于内部操作。要解决此问题,请重命名索引、别名或字段,不要使用前导下划线。如果错误是由于数据中的字段名引起的,您可能需要预处理数据来重命名字段。或者,您可以在索引期间使用脚本或摄取节点来重命名字段。 日志上下文 ----------- 日志 "must not start with '_'." 的类名是 [IndexNameExpressionResolver.java.](https://www.geeksforgeeks.org/java-lang-class-class-java-set-1/) 我们从 Elasticsearch 源代码中提取了以下内容,供那些寻求深入背景的人参考: ```java // Expressions can not start with an underscore. This is reserved for APIs. If the check gets here; the API // does not exist and the path is interpreted as an expression. If the expression begins with an underscore; // throw a specific error that is different from the [[IndexNotFoundException]]; which is typically thrown // if the expression can't be found. if (expression.expression().charAt(0) == '_') { throw new InvalidIndexNameException(expression.expression(); "must not start with '_'."); } private static void ensureRemoteIndicesRequireIgnoreUnavailable(IndicesOptions options; ListindexExpressions) { if (options.ignoreUnavailable() == false) { ```