# Need to delete the data from Indices A based on Indices B

**URL:** <https://discuss.elastic.co/t/need-to-delete-the-data-from-indices-a-based-on-indices-b/353744>\
**Category:** Elasticsearch\
**Created:** [February 21, 2024, 3:29am UTC](https://discuss.elastic.co/t/need-to-delete-the-data-from-indices-a-based-on-indices-b/353744 "2024-02-21T03:29:27Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Tqvenkata](https://avatars.discourse-cdn.com/v4/letter/t/e5b9ba/32.png) [@Tqvenkata](https://discuss.elastic.co/u/Tqvenkata)\
**Post date:** [February 21, 2024, 3:29am UTC](https://discuss.elastic.co/t/need-to-delete-the-data-from-indices-a-based-on-indices-b/353744/1 "2024-02-21T03:29:27Z")

</div>

HI, Is there any solution to delete the data from Indices A which are not exists(based on key) in Indices B in elasticsearch.

---

<div class="post-metadata">

**Author:** ![martianzz](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/martianzz/32/136041_2.png) [@martianzz](https://discuss.elastic.co/u/martianzz)\
**Post date:** [February 21, 2024, 4:57am UTC](https://discuss.elastic.co/t/need-to-delete-the-data-from-indices-a-based-on-indices-b/353744/2 "2024-02-21T04:57:02Z")

</div>

Can you kindly elaborate your issue

---

<div class="post-metadata">

**Author:** ![Tqvenkata](https://avatars.discourse-cdn.com/v4/letter/t/e5b9ba/32.png) [@Tqvenkata](https://discuss.elastic.co/u/Tqvenkata)\
**Post date:** [February 22, 2024, 6:15am UTC](https://discuss.elastic.co/t/need-to-delete-the-data-from-indices-a-based-on-indices-b/353744/3 "2024-02-22T06:15:10Z")

</div>

Please find the sample test data.

## Indices A

ID Name  
1 king  
2 charles  
3 Joy

## Indices B

ID Name  
1 King  
3 Joy

Now I need to delete data from Indices A based on Indices B (id is Key).  
If ID is not exist in Indices B then delete that data from Indices A

So finally I will need to get the Data from Indices A as below

ID Name  
1 King  
3 Joy

---

<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:** [March 21, 2024, 6:15am UTC](https://discuss.elastic.co/t/need-to-delete-the-data-from-indices-a-based-on-indices-b/353744/4 "2024-03-21T06:15:51Z")

</div>

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