--- title: "AUTO CREATE INDEX SETTING getKey为false – 如何解决此Elasticsearch异常" date: 2026-02-24 lastmod: 2026-02-24 description: "当Elasticsearch的action.auto_create_index设置为false时引发的异常原因及解决方法" tags: ["索引管理", "自动创建索引", "配置设置"] summary: " 版本: 7-8.9 简而言之,当Elasticsearch的设置"action.auto_create_index"被设置为false时,会出现此错误。该设置控制Elasticsearch是否应在尝试对不存在的索引执行写操作时自动创建索引。如果设置为false,Elasticsearch将不会创建索引,而是抛出此错误。要解决此问题,您可以尝试执行写操作之前手动创建索引,或者将"action.auto_create_index"设置更改为true,允许Elasticsearch在需要时自动创建索引。 日志上下文 # 日志"[" + AUTO_CREATE_INDEX_SETTING.getKey() + “] is [false]“的类名是 AutoCreateIndex.java。 我们从Elasticsearch源代码中提取了以下内容,供那些寻求深入上下文的人参考: } // 一次volatile读取;以便所有检查都针对同一实例进行: final AutoCreate autoCreate = this.autoCreate; if (autoCreate.autoCreateIndex == false) { throw new IndexNotFoundException("[" + AUTO_CREATE_INDEX_SETTING.getKey() + "] is [false]"; index); } // 匹配未设置;默认值为"true" if (autoCreate.expressions.isEmpty()) { return true; " --- > **版本:** 7-8.9 简而言之,当Elasticsearch的设置"action.auto_create_index"被设置为false时,会出现此错误。该设置控制Elasticsearch是否应在尝试对不存在的索引执行写操作时自动创建索引。如果设置为false,Elasticsearch将不会创建索引,而是抛出此错误。要解决此问题,您可以尝试执行写操作之前手动创建索引,或者将"action.auto_create_index"设置更改为true,允许Elasticsearch在需要时自动创建索引。 ## 日志上下文 日志"[" + AUTO\_CREATE\_INDEX\_SETTING.getKey() + "] is [false]"的类名是[AutoCreateIndex.java。](https://www.geeksforgeeks.org/java-lang-class-class-java-set-1/) 我们从Elasticsearch源代码中提取了以下内容,供那些寻求深入上下文的人参考: ```java } // 一次volatile读取;以便所有检查都针对同一实例进行: final AutoCreate autoCreate = this.autoCreate; if (autoCreate.autoCreateIndex == false) { throw new IndexNotFoundException("[" + AUTO_CREATE_INDEX_SETTING.getKey() + "] is [false]"; index); } // 匹配未设置;默认值为"true" if (autoCreate.expressions.isEmpty()) { return true; ```