# Delete old document automatically (version 6.5.4)

**URL:** <https://discuss.elastic.co/t/delete-old-document-automatically-version-6-5-4/320007>\
**Category:** Elasticsearch\
**Created:** [November 29, 2022, 7:57am UTC](https://discuss.elastic.co/t/delete-old-document-automatically-version-6-5-4/320007 "2022-11-29T07:57:49Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![gyrao\_72](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/gyrao_72/32/108254_2.png) [@gyrao\_72](https://discuss.elastic.co/u/gyrao_72)\
**Post date:** [November 29, 2022, 7:57am UTC](https://discuss.elastic.co/t/delete-old-document-automatically-version-6-5-4/320007/1 "2022-11-29T07:57:49Z")

</div>

I want to delete old documents from elastic whenever a new record is inserted with the same request\_id through logstash  
Example:  
Suppose my first log to be inserted in elastic is

```auto
6b06a196-0f9e-4bec-9c2c-17f4f6cdd652 tenant cloud data-1

```

Here _6b06a196-0f9e-4bec-9c2c-17f4f6cdd652_ is my request\_id  
New Log is

```auto
6b06a196-0f9e-4bec-9c2c-17f4f6cdd652 tenant cloud data-2

```

So now when a new log is processed I want to delete the previous record corresponding to **request\_id** from elastic

---

<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:** [November 29, 2022, 8:06am UTC](https://discuss.elastic.co/t/delete-old-document-automatically-version-6-5-4/320007/2 "2022-11-29T08:06:09Z")

</div>

If you are indexing into a single index and not using time-based indices you would need to consistently use the request\_id as document id to make the second document override the first. If not, then you need to explicitly perform a delete operation as there is no automatic way to ensure uniqueness across indices.

You are also running a very old version that has been EOL for a long time, so I would recommend you upgrade to the latest version.

---

<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 27, 2022, 8:07am UTC](https://discuss.elastic.co/t/delete-old-document-automatically-version-6-5-4/320007/3 "2022-12-27T08:07:06Z")

</div>

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