--- title: "索引不存在且自动创建索引设置为false – 如何解决此Elasticsearch异常" date: 2026-03-18 lastmod: 2026-03-18 description: "当Elasticsearch尝试自动创建不存在的索引,但自动创建索引设置被设为false时,会出现此错误。本文介绍解决方案。" tags: ["索引管理", "自动创建索引", "索引配置"] summary: "版本: 6.8-6.8 简要来说,当Elasticsearch尝试自动创建不存在的索引,但自动创建索引设置被设为false时,会出现此错误。该设置会阻止Elasticsearch自动创建索引。要解决此问题,您可以在向索引添加文档之前手动创建索引,或者将自动创建索引设置更改为true,允许Elasticsearch根据需要自动创建索引。但请注意,如果使用了错误的索引名称,允许自动创建索引可能会导致意外的索引创建。 日志上下文 # 日志 “no such index and [” + AUTO_CREATE_INDEX_SETTING.getKey() + “] is [false]” 的类名是 AutoCreateIndex.java. 我们从Elasticsearch源代码中提取了以下内容,供那些寻求深入了解上下文的人参考: return false; } // One volatile read; so that all checks are done against the same instance: final AutoCreate autoCreate = this.autoCreate; if (autoCreate.autoCreateIndex == false) { throw new IndexNotFoundException("no such index and [" + AUTO_CREATE_INDEX_SETTING.getKey() + "] is [false]", index); } if (dynamicMappingDisabled) { throw new IndexNotFoundException("no such index and [" + MapperService." --- > **版本:** 6.8-6.8 简要来说,当Elasticsearch尝试自动创建不存在的索引,但自动创建索引设置被设为false时,会出现此错误。该设置会阻止Elasticsearch自动创建索引。要解决此问题,您可以在向索引添加文档之前手动创建索引,或者将自动创建索引设置更改为true,允许Elasticsearch根据需要自动创建索引。但请注意,如果使用了错误的索引名称,允许自动创建索引可能会导致意外的索引创建。 日志上下文 ----------- 日志 "no such index and [" + AUTO\_CREATE\_INDEX\_SETTING.getKey() + "] is [false]" 的类名是 [AutoCreateIndex.java.](https://www.geeksforgeeks.org/java-lang-class-class-java-set-1/) 我们从Elasticsearch源代码中提取了以下内容,供那些寻求深入了解上下文的人参考: ```java return false; } // One volatile read; so that all checks are done against the same instance: final AutoCreate autoCreate = this.autoCreate; if (autoCreate.autoCreateIndex == false) { throw new IndexNotFoundException("no such index and [" + AUTO_CREATE_INDEX_SETTING.getKey() + "] is [false]", index); } if (dynamicMappingDisabled) { throw new IndexNotFoundException("no such index and [" + MapperService.INDEX_MAPPER_DYNAMIC_SETTING.getKey() + "] is [false]"; index); } ```