# Updating elasticsearch entities with bulk

**URL:** <https://discuss.elastic.co/t/updating-elasticsearch-entities-with-bulk/254936>\
**Category:** Elasticsearch\
**Created:** [November 10, 2020, 3:30pm UTC](https://discuss.elastic.co/t/updating-elasticsearch-entities-with-bulk/254936 "2020-11-10T15:30:11Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Alex12](https://avatars.discourse-cdn.com/v4/letter/a/3ec8ea/32.png) [@Alex12](https://discuss.elastic.co/u/Alex12)\
**Post date:** [November 10, 2020, 3:30pm UTC](https://discuss.elastic.co/t/updating-elasticsearch-entities-with-bulk/254936/1 "2020-11-10T15:30:12Z")

</div>

I have this database data as below (ES 7.xx) version

```auto
    {
   "id":"1234",
   "expirationDate":"17343234234",
   "paths":"http:localhost:9090",
   "work":"software dev",
   "family":{
      "baba":"jams",
      "mother":"ela"
   }
},
{
   "id":"00021",
   "expirationDate":"0123234",
   "paths":"http:localhost:8080",
   "work":"software engi",
   "family":{
      "baba":"stev",
      "mother":"hela"
   }
}

```

how can i update the entity which its expirationDate smaller than current Time? to be the current time for example:

the id 00021 is expired because its expiration date is smaller than today then it should updated to current time.

something like `void updateExpiredEntity(List<ids> ids,Long currentTime)` suing `void bulkUpdate(List<UpdateQuery> queries, BulkOptions bulkOptions, IndexCoordinates index);`

Please provide me some code implementation

my try, but i know its not all correct

```auto
   public void update(UUID id,Long currentDate) {
            UpdateQuery updateQuery = UpdateQuery.builder(id.toString()).withRouting("expirationDate=currentDate")
                .build();
            elasticsearchTemplate.bulkUpdate(List.of(updateQuery), IndexCoordinates.of("index"));
        }
    }

```

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [December 8, 2020, 3:30pm UTC](https://discuss.elastic.co/t/updating-elasticsearch-entities-with-bulk/254936/2 "2020-12-08T15:30:20Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
