--- title: "索引不存在与自动创建索引设置 getKey – 如何解决此 Elasticsearch 异常" date: 2026-01-10 lastmod: 2026-01-10 description: "当 Elasticsearch 尝试访问不存在的索引且自动创建索引功能被禁用时,会出现此错误。本文介绍如何解决此异常。" tags: ["索引", "配置", "异常处理"] summary: " 版本: 6.8-6.8 简而言之,当 Elasticsearch 尝试访问一个不存在的索引,并且自动创建索引设置被禁用时,就会出现此错误。当启用此设置时,Elasticsearch 可以在写入操作期间自动创建不存在的索引。要解决此问题,您可以手动创建索引后再尝试写入,或者通过将 Elasticsearch 配置更新为 “action.auto_create_index: true” 来启用自动创建索引设置。 日志上下文 # 日志 “no such index and [” + AUTO_CREATE_INDEX_SETTING.getKey() + “] ([” 类名是 AutoCreateIndex.java。 我们从 Elasticsearch 源代码中提取了以下内容,以供那些寻求深入背景信息的人参考: } throw new IndexNotFoundException("no such index and [" + AUTO_CREATE_INDEX_SETTING.getKey() + "] contains [-" + indexExpression + "] which forbids automatic creation of the index"; index); } } throw new IndexNotFoundException("no such index and [" + AUTO_CREATE_INDEX_SETTING.getKey() + "] ([" + autoCreate + "]) doesn't match"; index); } AutoCreate getAutoCreate() { return autoCreate; " --- > **版本:** 6.8-6.8 简而言之,当 Elasticsearch 尝试访问一个不存在的索引,并且自动创建索引设置被禁用时,就会出现此错误。当启用此设置时,Elasticsearch 可以在写入操作期间自动创建不存在的索引。要解决此问题,您可以手动创建索引后再尝试写入,或者通过将 Elasticsearch 配置更新为 "action.auto_create_index: true" 来启用自动创建索引设置。 日志上下文 ----------- 日志 "no such index and [" + AUTO\_CREATE\_INDEX\_SETTING.getKey() + "] ([" 类名是 [AutoCreateIndex.java。](https://www.geeksforgeeks.org/java-lang-class-class-java-set-1/) 我们从 Elasticsearch 源代码中提取了以下内容,以供那些寻求深入背景信息的人参考: ```java } throw new IndexNotFoundException("no such index and [" + AUTO_CREATE_INDEX_SETTING.getKey() + "] contains [-" + indexExpression + "] which forbids automatic creation of the index"; index); } } throw new IndexNotFoundException("no such index and [" + AUTO_CREATE_INDEX_SETTING.getKey() + "] ([" + autoCreate + "]) doesn't match"; index); } AutoCreate getAutoCreate() { return autoCreate; ```