ElasticSearch备考 -- Search scroll

一、题目

Search for all documents in all indices

As above, but use the scroll API to return the first 100 results

while keeping the search context alive for 2 minutes

Use the scroll id included in the response to the previous query

and retrieve the next batch of results

二、思考

题目要求查询所有索引,并且使用scroll api 查询100个文档,查询上下文要保持2分钟。

三、解题

Step 1、使用Scroll API查询

POST /*/_search?scroll=2m
{
    "size": 100,
    "query": {
        "match_all" : {
        }
    }
}

Step 2、获取id后查询下一页

注意这里使用的是get /_search/scroll ,参数需要传上次查询返回的scroll_id

四、总结

scroll api 常用于大量文档查询,这个有一定的查询性能消耗,而且对查询上下文有时间限制,超过上线问查询id则会失效。


参考资料

送一波福利:

福利一

有需要内推JD的同学,可以私信或留言,我帮您内推,流程快!!!

有需要内推JD的同学,可以私信或留言,我帮您内推,流程快!!!

有需要内推JD的同学,可以私信或留言,我帮您内推,流程快!!!

福利二

福利三

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值