简体   繁体   中英

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.

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:

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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