--- title: "文档未找到 index id – 如何解决此 Elasticsearch 异常" date: 2026-02-11 lastmod: 2026-02-11 description: "当 Elasticsearch 尝试使用特定的索引和 ID 检索文档时,但该文档在指定索引中不存在,会触发此错误。通常是由于文档被删除、索引不存在或 ID 不正确导致的。" tags: ["文档查询", "资源异常", "索引管理"] summary: "版本: 8-8.9 简要来说,当 Elasticsearch 尝试使用特定的索引和 ID 检索文档,但该文档在指定索引中不存在时,就会出现此错误。这可能是由于文档被删除、索引不存在或 ID 不正确造成的。要解决此问题,您可以验证索引和文档 ID 的存在性。如果索引或文档 ID 不正确,请予以更正。如果文档已被删除,您可能需要重新创建它,或者在可用的情况下从备份中恢复它。 日志上下文 # 日志 “Document not found [” + index + “]/[” + id + “]” 类名是 RestGetSourceAction.java。我们从 Elasticsearch 源代码中提取了以下内容,供那些寻求深入上下文的人参考: private static void checkResource(final GetResponse response) { final String index = response.getIndex(); final String id = response.getId(); if (response.isExists() == false) { throw new ResourceNotFoundException("Document not found [" + index + "]/[" + id + "]"); } else if (response." --- > **版本:** 8-8.9 简要来说,当 Elasticsearch 尝试使用特定的索引和 ID 检索文档,但该文档在指定索引中不存在时,就会出现此错误。这可能是由于文档被删除、索引不存在或 ID 不正确造成的。要解决此问题,您可以验证索引和文档 ID 的存在性。如果索引或文档 ID 不正确,请予以更正。如果文档已被删除,您可能需要重新创建它,或者在可用的情况下从备份中恢复它。 日志上下文 ----------- 日志 "Document not found [" + index + "]/[" + id + "]" 类名是 [RestGetSourceAction.java](https://www.geeksforgeeks.org/java-lang-class-class-java-set-1/)。我们从 Elasticsearch 源代码中提取了以下内容,供那些寻求深入上下文的人参考: ```java private static void checkResource(final GetResponse response) { final String index = response.getIndex(); final String id = response.getId(); if (response.isExists() == false) { throw new ResourceNotFoundException("Document not found [" + index + "]/[" + id + "]"); } else if (response.isSourceEmpty()) { throw new ResourceNotFoundException("Source not found [" + index + "]/[" + id + "]"); } } } ```