es默认结果集最大行数为10000行,超过10000行 会报错,
解决方法:
一,修改配置
语句
PUT /index/_settings
{ "index.max_result_window" :"500000"}//最大行数
查看
GET /index/_settings
再次查询 正常
二,采用滚动搜索 Scroll
一般搜索请求都是返回一"页"数据,无论数据量多大都一起返回给用户,Scroll API可以允许我们检索大量数据(甚至全部数据)。Scroll API允许我们做一个初始阶段搜索并且持续批量从Elasticsearch里拉取结果直到没有结果剩下。这有点像传统数据库里的cursors(游标)。
Scroll API的创建并不是为了实时的用户响应,而是为了处理大量的数据(Scrolling is not intended for real time user requests, but rather for processing large amounts of data)。从 scroll 请求返回的结果只是反映了 search 发生那一时刻的索引状态,就像一个快照(The results that are returned from a scroll request reflect the state of the index at the time that the initial search request was made, like a snapshot in time)。后续的对文档的改动(索引、更新或者删除)都只会影响后面的搜索请求。
参考文档:
https://blog.csdn.net/u014589856/article/details/78775233
https://www.elastic.co/guide/en/elasticsearch/reference/2.4/search-request-scroll.html