背景
后台查詢訂單列表,將mysql查詢改造為es查詢.分頁展示,每頁10條數據,當查詢頁數超過1000頁時,發現后台es報錯,報錯信息為:
(’Result window is too large, from + size must be less than or equal to: [10000] but was [10100].
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.’)
分析
分析報錯信息,明顯提示結果窗口集太大了,條數不應該超過10000條.這是因為ElasticSearch默認查詢10000條展示(官網有說明),當超過10000條時,就會報錯
解決方式
可以通過elasticsearch-head插件解決
1.關閉索引庫
2.點擊復合查詢
3.執行PUT語法(這里數值修改為足夠大)
4.查看返回結果(true代表成功)
5.打開索引庫
注意:執行PUT語法時可能會報錯 :
Content-Type header [application/x-www-form-urlencoded] is not supported
解決方法如下:
修改head插件目錄下的vendor.js文件的6886行和7573行
將application/x-www-form-urlencoded 替換為 application/json;charset=UTF-8
再次執行PUT語句即可