简体   繁体   中英

How to conditionally update the elasticsearch document?

Using update query for document as follows:

/<indexname>/_update/<id>
{
    doc: {
        /// the doc here
    }
}

Is there a way, I can put condition like created_at field in the existing doc is less than created_at we are passing?

You are probably looking for update by query api.

eg

POST <index>/_update_by_query
{
  "query": { 
    "range": {
      "created_at": {
         "lte": "2019-01-10"
      }
    }
  }
}

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