简体   繁体   English

Elasticsearch 按查询更新 - 仅更新具有最小时间戳的文档

[英]Elasticsearch update by query - update only document with minimum timestamp

I am new to the elasticsearch and I am trying to get the first document from my index and update its list of object.我是 elasticsearch 的新手,我试图从我的索引中获取第一个文档并更新它的对象列表。

I tried several queries eg:我尝试了几个查询,例如:

POST localhost:9200/test-index/_update_by_query

{
 "size":1,
 "sort": [{"timestamp":"asc"}],
  "script": {
      "inline": "ctx._source.addresses.add(params.address)",
        "params" : {
           "address" :{
                  "street": "Yemen Road",
                  "number": 15,
                  "county": "Yemen"
              }
        }
    }
}

But this updates all my documents.但这会更新我的所有文件。 What is the fastest way to do this?执行此操作的最快方法是什么?

Thank you in advance!先感谢您!

I got the following answer from the elasticsearch community:我从elasticsearch社区得到了以下答案:

Update by query does not support a size.按查询更新不支持大小。 You would need to run a query first using size and sorting, and then use the update API on that single document.您需要先使用大小和排序运行查询,然后在该单个文档上使用更新 API。

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

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