# Delete from read indexes

**URL:** <https://discuss.elastic.co/t/delete-from-read-indexes/275919>\
**Category:** Elasticsearch\
**Created:** [June 15, 2021, 2:49am UTC](https://discuss.elastic.co/t/delete-from-read-indexes/275919 "2021-06-15T02:49:56Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![Deepti](https://avatars.discourse-cdn.com/v4/letter/d/ee7513/32.png) [@Deepti](https://discuss.elastic.co/u/Deepti)\
**Post date:** [June 15, 2021, 2:49am UTC](https://discuss.elastic.co/t/delete-from-read-indexes/275919/1 "2021-06-15T02:49:56Z")

</div>

Hello,  
I have a current write index and multiple read indexes .Is it possible to delete the documents from only the read indexes? Document with same ID will be present in both read and write index but I want the document to be deleted only from read index.

Thanks

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [June 15, 2021, 3:22am UTC](https://discuss.elastic.co/t/delete-from-read-indexes/275919/2 "2021-06-15T03:22:19Z")

</div>

> [@Deepti](#):
>
> Is it possible to delete the documents from only the read indexes

Yes. If you are referring to ILM then the underlying indices are still standard Elasticsearch indices and can be manipulated.

---

<div class="post-metadata">

**Author:** ![Christian\_Dahlqvist](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/christian_dahlqvist/32/4617_2.png) [@Christian\_Dahlqvist](https://discuss.elastic.co/u/Christian_Dahlqvist)\
**Post date:** [June 15, 2021, 3:31am UTC](https://discuss.elastic.co/t/delete-from-read-indexes/275919/3 "2021-06-15T03:31:47Z")

</div>

It sounds like you want to delete from all indices in the index pattern except the one pointed to by the write alias. Is that correct? If so, that is as Mark pointed out possible but I do not think there is any easy way of addressing just these indices so you probably need a two stage process to find out which indices are to be deleted from and then list these explicitly.

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [June 15, 2021, 3:34am UTC](https://discuss.elastic.co/t/delete-from-read-indexes/275919/4 "2021-06-15T03:34:28Z")

</div>

It should be as easy as `index-pattern-0*`, as the alias is likely going to be `index-pattern` and all the underlying indices will have numbers preceding them.

That's assuming the defaults though.

---

<div class="post-metadata">

**Author:** ![Christian\_Dahlqvist](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/christian_dahlqvist/32/4617_2.png) [@Christian\_Dahlqvist](https://discuss.elastic.co/u/Christian_Dahlqvist)\
**Post date:** [June 15, 2021, 3:37am UTC](https://discuss.elastic.co/t/delete-from-read-indexes/275919/5 "2021-06-15T03:37:36Z")

</div>

That would however include the index currently being written to and not just the read indices.

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [June 15, 2021, 3:39am UTC](https://discuss.elastic.co/t/delete-from-read-indexes/275919/6 "2021-06-15T03:39:13Z")

</div>

Yeah, good point!

---

<div class="post-metadata">

**Author:** ![Christian\_Dahlqvist](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/christian_dahlqvist/32/4617_2.png) [@Christian\_Dahlqvist](https://discuss.elastic.co/u/Christian_Dahlqvist)\
**Post date:** [June 15, 2021, 3:39am UTC](https://discuss.elastic.co/t/delete-from-read-indexes/275919/7 "2021-06-15T03:39:34Z")

</div>

It might help if you described your use case. Maybe ILM with rollover is not the best fit for your requirements if you need to update documents and maintain only a single copy.

---

<div class="post-metadata">

**Author:** ![Deepti](https://avatars.discourse-cdn.com/v4/letter/d/ee7513/32.png) [@Deepti](https://discuss.elastic.co/u/Deepti)\
**Post date:** [June 15, 2021, 4:10am UTC](https://discuss.elastic.co/t/delete-from-read-indexes/275919/8 "2021-06-15T04:10:17Z")

</div>

@Christian_Dahlqvist the use case here is as soon as I update the document in the write index ,I no longer need the other documents with the same ID which are present in read index, because when I try to get the documents I need the latest one, so I want to delete the documents in read index asynchronously, basically deletion of documents in read index should happen as a post process of updating a document in write index

---

<div class="post-metadata">

**Author:** ![Christian\_Dahlqvist](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/christian_dahlqvist/32/4617_2.png) [@Christian\_Dahlqvist](https://discuss.elastic.co/u/Christian_Dahlqvist)\
**Post date:** [June 15, 2021, 4:12am UTC](https://discuss.elastic.co/t/delete-from-read-indexes/275919/9 "2021-06-15T04:12:27Z")

</div>

What drove the decision to use rollover? How much data do you have? How is this expected to grow over time? What are your requirements around retention? How frequently are documents updated?

---

<div class="post-metadata">

**Author:** ![Deepti](https://avatars.discourse-cdn.com/v4/letter/d/ee7513/32.png) [@Deepti](https://discuss.elastic.co/u/Deepti)\
**Post date:** [June 15, 2021, 4:29am UTC](https://discuss.elastic.co/t/delete-from-read-indexes/275919/10 "2021-06-15T04:29:21Z")

</div>

Once a document is updated I no longer need the older ones , Documents will be updated very frequently so when I try to get I just need the latest one, I don't need multiple documents with the same ID

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [June 15, 2021, 4:33am UTC](https://discuss.elastic.co/t/delete-from-read-indexes/275919/11 "2021-06-15T04:33:04Z")

</div>

Then using ILM for this doesn't make any sense.  
Use a single index and then just update the existing document.

---

<div class="post-metadata">

**Author:** ![Deepti](https://avatars.discourse-cdn.com/v4/letter/d/ee7513/32.png) [@Deepti](https://discuss.elastic.co/u/Deepti)\
**Post date:** [June 16, 2021, 3:45am UTC](https://discuss.elastic.co/t/delete-from-read-indexes/275919/12 "2021-06-16T03:45:30Z")

</div>

Thanks @warkolm @Christian_Dahlqvist

---

<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:** [July 14, 2021, 3:46am UTC](https://discuss.elastic.co/t/delete-from-read-indexes/275919/13 "2021-07-14T03:46:03Z")

</div>

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