es 深度分页问题
背景
使用es的from/size进行常规的分页操作时,有一个max_window_size限制,大小默认是10000,当from+size > 10000时,会有如下报错:
"error": {
"root_cause": [
{
"type": "query_phase_execution_exception",
"reason": "Result window is too large, from + size must be less than or equal to: [10000] but was [10001]. See the scroll api for a more efficient way to request large data sets. This limit can be set by changing the [index.max_result_window] index level setting."
}
],
"type": "search_phase_execution_exception",
"reason": "all shards failed",
"phase": "query",
"grouped": true,
"failed_shards": [
{
"shard": 0,
"index": "uat_defect_info",
"node": "nqwAvcL9QMqLKIo67GrI8A",
"reason": {
"type": "query_phase_execution_exception",

Elasticsearch的from/size分页存在max_window_size限制,超过10000会导致错误。为解决深度分页问题,可以使用scroll API,但不适合跳页场景;search_after依赖稳定排序,适用于连续翻页。注意,scroll和search_after不适用于频繁的页数跳转,且资源消耗较大。

3143

被折叠的 条评论
为什么被折叠?



