hatellla
hatellla

Reputation: 5132

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?

Upvotes: 0

Views: 1763

Answers (1)

Nishant
Nishant

Reputation: 7854

You are probably looking for update by query api.

e.g.

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

Upvotes: 2

Related Questions