Elasticsearch查询返回所有记录 [英] Elasticsearch query to return all records

查看:6503
本文介绍了Elasticsearch查询返回所有记录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Elasticsearch中有一个小型数据库,并且为了测试的目的,希望将所有记录都拉回来。我尝试使用以下形式的网址...

I have a small database in Elasticsearch and for testing purposes would like to pull all records back. I am attempting to use a URL of the form...

http://localhost:9200/foo/_search?pretty=true&q={'matchAll':{''}}

推荐答案

我认为lucene语法支持:

I think lucene syntax is supported so:

http:// localhost:9200 / foo / _search?pretty = true& q = *:*

size默认为10,因此您还可能需要& size = BIGNUMBER 才能获得超过10个项目。 (其中BIGNUMBER等于您认为大于您的数据集的数字)

size defaults to 10, so you may also need &size=BIGNUMBER to get more than 10 items. (where BIGNUMBER equals a number you believe is bigger than your dataset)

但是,elasticsearch文档为大型结果集建议

BUT, elasticsearch documentation suggests for large result sets, using the scan search type.

EG:

curl -XGET 'localhost:9200/foo/_search?search_type=scan&scroll=10m&size=50' -d '
{
    "query" : {
        "match_all" : {}
    }
}'

然后根据上面的文档链接继续请求。

and then keep requesting as per the documentation link above suggests.

scan 在2.1.0中弃用。

scan Deprecated in 2.1.0.

与按 _doc 排序的常规滚动请求相比没有提供任何好处。 指向弹性文档的链接(由@ christophe-roussy发现)

scan does not provide any benefits over a regular scroll request sorted by _doc. link to elastic docs (spotted by @christophe-roussy)

这篇关于Elasticsearch查询返回所有记录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆