--- title: "自动创建索引设置包含负值 - 如何解决此 Elasticsearch 异常" date: 2026-01-10 lastmod: 2026-01-10 description: "当 Elasticsearch 的 auto_create_index 设置包含负值时会导致此错误。该设置控制 Elasticsearch 在向不存在的索引索引文档时是否自动创建索引。负值是无效的。" tags: ["索引管理", "配置错误", "自动创建索引"] summary: " 版本: 7-7.15 简而言之,当 Elasticsearch 设置 “auto_create_index” 包含负值时,会发生此错误。该设置控制当文档被索引到不存在的索引时,Elasticsearch 是否应该自动创建索引。负值是无效的。要解决此问题,您可以将值设置为 true,允许自动创建索引,或设置为 false,禁止自动创建。或者,您可以指定应该允许或禁止自动创建的索引名称列表。 日志上下文 # 日志 “[” + AUTO_CREATE_INDEX_SETTING.getKey() + “] contains [-” 类名为 AutoCreateIndex.java。 我们从 Elasticsearch 源代码中提取了以下内容,以供那些寻求深入了解上下文的人参考: boolean include = expression.v2(); if (Regex.simpleMatch(indexExpression; index)) { if (include) { return true; } throw new IndexNotFoundException("[" + AUTO_CREATE_INDEX_SETTING.getKey() + "] contains [-" + indexExpression + "] which forbids automatic creation of the index"; index); } } throw new IndexNotFoundException("[" + AUTO_CREATE_INDEX_SETTING.getKey() + "] ([" + autoCreate + "]) doesn't match"; index); " --- > **版本:** 7-7.15 简而言之,当 Elasticsearch 设置 "auto_create_index" 包含负值时,会发生此错误。该设置控制当文档被索引到不存在的索引时,Elasticsearch 是否应该自动创建索引。负值是无效的。要解决此问题,您可以将值设置为 true,允许自动创建索引,或设置为 false,禁止自动创建。或者,您可以指定应该允许或禁止自动创建的索引名称列表。 ## 日志上下文 日志 "[" + AUTO\_CREATE\_INDEX\_SETTING.getKey() + "] contains [-" 类名为 [AutoCreateIndex.java。](https://www.geeksforgeeks.org/java-lang-class-class-java-set-1/) 我们从 Elasticsearch 源代码中提取了以下内容,以供那些寻求深入了解上下文的人参考: ```java boolean include = expression.v2(); if (Regex.simpleMatch(indexExpression; index)) { if (include) { return true; } throw new IndexNotFoundException("[" + AUTO_CREATE_INDEX_SETTING.getKey() + "] contains [-" + indexExpression + "] which forbids automatic creation of the index"; index); } } throw new IndexNotFoundException("[" + AUTO_CREATE_INDEX_SETTING.getKey() + "] ([" + autoCreate + "]) doesn't match"; index); ```