使用es存儲(chǔ)查詢時(shí)有分頁(yè)功能琅拌,數(shù)據(jù)量較少時(shí)并沒(méi)有發(fā)現(xiàn)該問(wèn)題。但是當(dāng)數(shù)據(jù)量比較大時(shí)曹铃,要查詢第101頁(yè)的數(shù)據(jù)缰趋,每頁(yè)數(shù)據(jù)量為100捧杉,100頁(yè)數(shù)據(jù)相當(dāng)于要查第10000條以后的數(shù)據(jù)陕见,這時(shí)發(fā)現(xiàn)es查詢報(bào)錯(cuò):
Result window is too large, from + size must be less than or equal to: [10000] but was [10025].
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 parameter.
從字面理解,es的默認(rèn)的結(jié)果集窗口是10000味抖,但是你要查詢到10025條數(shù)據(jù)评甜;這里可以采用es的scroll api查詢;或者通過(guò)改變索引的max_result_window的屬性值仔涩。
上述的scroll api返回結(jié)果集為非排序的忍坷,不滿足業(yè)務(wù)需求,所以不采用熔脂。
采用修改索引的max_result_window屬性值佩研。
修改方法如下:
PUT your_index/_settings
{
"index":{
"max_result_window":1000000
}
}
返回結(jié)果:
{
"acknowledged": true
}
然后再進(jìn)行查詢,發(fā)現(xiàn)可以正常返回了霞揉。