簡體   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