search_context_missing_exception: No search context found for id (scroll expired)(找不到该 id 的搜索上下文,scroll 已过期)
Elasticsearch含义
scroll 查询所使用的搜索上下文在服务器上已不存在。通常在 scroll 上下文已超时或被清除后,仍使用保存的 scroll_id 继续查询时出现。
原因
为 scroll 指定的 keep-alive 已过期(请求之间的间隔太长);上下文被手动清除(clear scroll);或节点重启导致上下文丢失。scroll 上下文保存在节点内存中,因此生命周期有限。
解决方法
在每个 scroll 请求中传入足够的 keep-alive(例如 scroll=5m),并缩短翻页之间的延迟。在新版 Elasticsearch 中,深度分页应使用 search_after + Point in Time(PIT)代替 scroll;这种方式扩展性更好,也是推荐做法。用完后释放上下文(clear scroll),以免浪费内存。
同一数据库的其他条目
- invalid_index_name_exceptioninvalid_index_name_exception
- resource_not_found_exceptionresource_not_found_exception
- process_cluster_event_timeout_exceptionprocess_cluster_event_timeout_exception
- aliases_not_found_exceptionAliases missing(别名不存在)
- snapshot_missing_exceptionSnapshot is missing(快照不存在)
- index_template_missing_exceptionIndex template is missing(索引模板不存在)
- settings_exceptionInvalid settings(无效的设置)