# Overwrite index when the new input file is discovered

**URL:** <https://discuss.elastic.co/t/overwrite-index-when-the-new-input-file-is-discovered/365438>\
**Category:** Logstash\
**Created:** [August 23, 2024, 7:52am UTC](https://discuss.elastic.co/t/overwrite-index-when-the-new-input-file-is-discovered/365438 "2024-08-23T07:52:38Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![chun](https://avatars.discourse-cdn.com/v4/letter/c/a87d85/32.png) [@chun](https://discuss.elastic.co/u/chun)\
**Post date:** [August 23, 2024, 7:52am UTC](https://discuss.elastic.co/t/overwrite-index-when-the-new-input-file-is-discovered/365438/1 "2024-08-23T07:52:38Z")

</div>

I have a logstash configuration below reading a large jason file dumped by seperate python code. The ask is to refresh the index with the new data on daily basis. How to clear the old data from index before reading the new data?

```auto
input{
	
	file {
		mode => "read"
		path => ["c:/EDM/tools/dremio_dashboard/sys_jobs_recent.json"]
		file_completed_action => "log_and_delete"
		file_completed_log_path => "c:/EDM/tools/dremio_dashboard/archive"
		codec => json
	}
}

output {
 
  stdout {
    codec => rubydebug {}
  }
  elasticsearch {
	hosts => ["http://localhost:9200"]
	index => "dremio_sys_jobs_recent"
  }	
}

```

---

<div class="post-metadata">

**Author:** ![Tortoise](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/tortoise/32/147587_2.png) [@Tortoise](https://discuss.elastic.co/u/Tortoise)\
**Post date:** [August 23, 2024, 8:29am UTC](https://discuss.elastic.co/t/overwrite-index-when-the-new-input-file-is-discovered/365438/2 "2024-08-23T08:29:41Z")

</div>

Hello,

You need to use rollover index : [Rollover | Elasticsearch Guide [8.15] | Elastic](https://www.elastic.co/guide/en/elasticsearch/reference/current/ilm-rollover.html)  
To manage old indexes need to create/review ILM polices.

Thanks!
