document_missing_exception: document_missing_exception: [_doc][id]: document missing(文档不存在)
Elasticsearch含义
在索引中找不到要更新(_update)的文档。更新要求文档已存在;如果文档不存在,就会出现该异常。
原因
文档之前已被删除、从未创建、使用了错误的 _id、请求发到了错误的索引,或以自定义 routing 写入的文档在访问时未指定 routing。(GET 和 _update 是实时的;refresh 延迟不会导致该错误。)
解决方法
确认 _id 和目标索引正确:GET /index-name/_doc/id。如果需要存在则更新/不存在则创建的行为,在 _update 请求中使用 upsert(或 doc_as_upsert:true)。直接用 index(PUT)创建文档。在应用中捕获该异常并回退到 upsert 逻辑。
同一数据库的其他条目
- search_phase_execution_exceptionsearch_phase_execution_exception: all shards failed / Failed to execute phase [query](所有分片均失败 / 执行 [query] 阶段失败)
- too_many_clausestoo_many_clauses: maxClauseCount is set to 1024 (query contains too many clauses)(查询包含的子句过多)
- version_conflict_engine_exceptionversion_conflict_engine_exception: [_doc][id]: version conflict, current version [x] is different than the one provided [y] (HTTP 409)(版本冲突,当前版本与提供的版本不同)
- index_not_found_exceptionindex_not_found_exception: no such index [index_name] (HTTP 404)(索引不存在)
- resource_already_exists_exceptionresource_already_exists_exception: index [index_name/uuid] already exists (HTTP 400)(索引已存在)
- cluster_health_redcluster health status: RED / unassigned shards(集群健康状态:RED / 未分配的分片)
- no_shard_available_action_exceptionno_shard_available_action_exception: No shard available for [...](没有可用的分片)