--- title: "未找到源 索引/类型/ID – 如何解决此 Elasticsearch 异常" date: 2026-02-25 lastmod: 2026-02-25 description: "当 Elasticsearch 尝试使用特定 ID 从索引中检索文档时,如果文档或索引本身不存在,就会发生此错误。本文介绍了如何验证索引和文档的存在性,以及如何解决此问题。" tags: ["文档查询", "索引管理", "资源不存在异常"] summary: " 版本: 6.8-7.17 简而言之,当 Elasticsearch 尝试使用特定 ID 从索引中检索文档时,如果文档或索引本身不存在,就会发生此错误。要解决此问题,您可以验证索引和文档是否存在。确保索引、类型和 ID 的拼写正确且区分大小写。如果文档不存在,您可能需要创建它。如果索引不存在,您可能需要先创建索引,然后再向其中添加文档。 日志上下文 # 日志 “Source not found [” + index + “]/[” + type + “]/[” + id + “]” 的类名是 RestGetSourceAction.java。 我们从 Elasticsearch 源代码中提取了以下内容,供那些寻求深入上下文的人参考: final String id = response.getId(); if (response.isExists() == false) { throw new ResourceNotFoundException("Document not found [" + index + "]/[" + type + "]/[" + id + "]"); } else if (response.isSourceEmpty()) { throw new ResourceNotFoundException("Source not found [" + index + "]/[" + type + "]/[" + id + "]"); } } } } " --- > **版本:** 6.8-7.17 简而言之,当 Elasticsearch 尝试使用特定 ID 从索引中检索文档时,如果文档或索引本身不存在,就会发生此错误。要解决此问题,您可以验证索引和文档是否存在。确保索引、类型和 ID 的拼写正确且区分大小写。如果文档不存在,您可能需要创建它。如果索引不存在,您可能需要先创建索引,然后再向其中添加文档。 日志上下文 ----------- 日志 "Source not found [" + index + "]/[" + type + "]/[" + id + "]" 的类名是 [RestGetSourceAction.java。](https://www.geeksforgeeks.org/java-lang-class-class-java-set-1/) 我们从 Elasticsearch 源代码中提取了以下内容,供那些寻求深入上下文的人参考: ```java final String id = response.getId(); if (response.isExists() == false) { throw new ResourceNotFoundException("Document not found [" + index + "]/[" + type + "]/[" + id + "]"); } else if (response.isSourceEmpty()) { throw new ResourceNotFoundException("Source not found [" + index + "]/[" + type + "]/[" + id + "]"); } } } } ```