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

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

问题描述

我在 Elasticsearch 中有一个小型数据库,出于测试目的,我想拉回所有记录.我正在尝试使用表单的 URL...

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':{''}}

有人可以给我您用来完成此操作的网址吗?

Can someone give me the URL you would use to accomplish this, please?

推荐答案

我认为 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.

scan 与按 _doc 排序的常规 scroll 请求相比没有任何好处.弹性文档链接(由@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天全站免登陆