繁体   English   中英

有什么方法可以使用curl查询多个文档以从_source提取字段值来查询elasticsearch吗?

[英]Is there any way to query elasticsearch using curl for multiple documents to extract field values from _source?

我正在寻找卷曲查询来查询索引中的多个唯一文档ID。 就像我们知道的那样,文档的实际数据存储在“ _source”下,但是到目前为止,我已经能够为源中的必填字段查询单个document_id,而不能查询包含过滤器的多个文档。 我认为'mget'在这里会有所帮助

  • GET //// _源

例如-

curl -XGET "http://localhost:9200/my_index/document/id/_source?_source_include=_id_batch" -d "{"query":{"bool":{"must":[{"term":{"_doc_date":"20150122"}}],"from": 0,"fields":[],"size":5,"sort":[]}" > "C:\Users\user.id\Downloads\output.json"

样本索引-

索引Snap_shot

实际上有mget API:

http://www.elastic.co/guide/en/elasticsearch/reference/current/docs-multi-get.html

使用您的示例,您可以执行以下操作:

curl 'localhost:9200/my_index/_mget' -d '{
    "docs" : [
        {
            "_type" : "document",
            "_id" : "1"
        },
        {
            "_type" : "document",
            "_id" : "2"
        }
    ]
}'

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM