【问题标题】:Elasticsearch return all documents of a given typeElasticsearch 返回给定类型的所有文档
【发布时间】:2017-07-30 10:14:53
【问题描述】:

我这几天一直在寻找这个问题的解决方案。用例是仅查看特定类型的文档。通常在谷歌搜索很长时间后,我最终会得到一些带有通配符的搜索查询。我也浏览过很多 SO 帖子,例如 thisthiselastic documentation。我尝试了以下网址,但没有任何运气。

curl -XGET 'localhost:9200/analytics/test/_search' -d '
{

   "query" : {
   "match_all" : {}
    }
}'

curl -XGET 'localhost:9200/analytics/test/_search' -d '
{
    "query": {
        "type":{
            "value": "test"
            }
    }
}'

是否有类似对文档类型的通配符搜索以返回该特定 doc_type 的所有文档?

【问题讨论】:

  • 返回所有文件 - 使用:curl localhost:9200/analytics/test/_search。但是doc_type 是什么意思?
  • 默认情况下elasticsearch只会返回10个文档……你需要增加size参数……虽然如果结果非常大,建议使用分页查询
  • @VladimirKovpak doc_type 是localhost:9200/<index>/<doc_type> 中的文档类型。

标签: search elasticsearch types document document-types


【解决方案1】:

要从类型test 中获取索引analytics 中的所有文档,只需运行:

curl -XGET localhost:9200/analytics/test/_search

curl -XGET localhost:9200/analytics/test/_search -d '{
    "query": {"match_all" : {}}
}'

如果您的用户数超过默认大小值,则需要提供from/size 值,如here 所述。

【讨论】:

    猜你喜欢
    • 2021-08-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-12-08
    • 2015-11-26
    • 2014-05-20
    • 2021-10-31
    • 1970-01-01
    相关资源
    最近更新 更多