--- title: "文档未找到 index type id – 如何解决此 Elasticsearch 异常" date: 2026-02-19 lastmod: 2026-02-19 description: "当 Elasticsearch 尝试通过索引、类型和 ID 访问文档但文档不存在时,会出现此错误。" tags: ["文档未找到", "索引错误", "ResourceNotFoundException"] summary: "版本: 6.8-7.17 简要来说,当 Elasticsearch 尝试使用索引、类型和 ID 访问文档时,如果该文档不存在,就会出现此错误。这可能是由于文档已被删除、索引未创建或 ID 不正确导致的。要解决此问题,你可以使用带有正确索引和 ID 的 ‘GET’ API 来验证文档是否存在。如果文档不存在,你可能需要重新创建它。如果索引不存在,则需要创建索引。最后,确保你使用的 ID 是正确的。 日志上下文 # 日志 “Document not found [” + index + “]/[” + type + “]/[” + id + “]” 的类名是 RestGetSourceAction.java。我们从 Elasticsearch 源代码中提取了以下内容,供那些需要深入了解上下文的用户参考: final String index = response.getIndex(); final String type = response.getType(); final String id = response.getId(); if (response.isExists() == false) { throw new ResourceNotFoundException("Document not found [" + index + "]/[" + type + "]/[" + id + "]"); } else if (response." --- > **版本:** 6.8-7.17 简要来说,当 Elasticsearch 尝试使用索引、类型和 ID 访问文档时,如果该文档不存在,就会出现此错误。这可能是由于文档已被删除、索引未创建或 ID 不正确导致的。要解决此问题,你可以使用带有正确索引和 ID 的 'GET' API 来验证文档是否存在。如果文档不存在,你可能需要重新创建它。如果索引不存在,则需要创建索引。最后,确保你使用的 ID 是正确的。 日志上下文 ----------- 日志 "Document not found [" + index + "]/[" + type + "]/[" + id + "]" 的类名是 [RestGetSourceAction.java](https://www.geeksforgeeks.org/java-lang-class-class-java-set-1/)。我们从 Elasticsearch 源代码中提取了以下内容,供那些需要深入了解上下文的用户参考: ```java final String index = response.getIndex(); final String type = response.getType(); 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 + "]"); } } } ```