# Deleting old Docs from particular index using curator plugin

**URL:** <https://discuss.elastic.co/t/deleting-old-docs-from-particular-index-using-curator-plugin/137546>\
**Category:** Elasticsearch\
**Created:** [June 27, 2018, 6:38am UTC](https://discuss.elastic.co/t/deleting-old-docs-from-particular-index-using-curator-plugin/137546 "2018-06-27T06:38:47Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![kish](https://avatars.discourse-cdn.com/v4/letter/k/71e660/32.png) [@kish](https://discuss.elastic.co/u/kish)\
**Post date:** [June 27, 2018, 6:38am UTC](https://discuss.elastic.co/t/deleting-old-docs-from-particular-index-using-curator-plugin/137546/1 "2018-06-27T06:38:47Z")

</div>

Hello -

I have installed curator plugin for deleting docs of particular index. So

1. Can curator plugin can be used to delete a Doc's of a index/indices OR it is only used to delete the entire indices. If possible can you share any sample.

2. To delete a indices also is it mandatory to have alias created for that indices.

---

<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 27, 2018, 6:57am UTC](https://discuss.elastic.co/t/deleting-old-docs-from-particular-index-using-curator-plugin/137546/2 "2018-06-27T06:57:10Z")

</div>

> [@kish](#):
>
> Can curator plugin can be used to delete a Doc's of a index/indices OR it is only used to delete the entire indices. If possible can you share any sample.

Curator deletes entire indices only.

> [@kish](#):
>
> To delete a indices also is it mandatory to have alias created for that indices.

No, aliases are not required nor expected.

---

<div class="post-metadata">

**Author:** ![kish](https://avatars.discourse-cdn.com/v4/letter/k/71e660/32.png) [@kish](https://discuss.elastic.co/u/kish)\
**Post date:** [June 27, 2018, 7:07am UTC](https://discuss.elastic.co/t/deleting-old-docs-from-particular-index-using-curator-plugin/137546/3 "2018-06-27T07:07:09Z")

</div>

> [@Christian\_Dahlqvist](#):
>
> Curator deletes entire indices only

Then is there any way to delete the Docs alone for particular indices? Because my indices will be loaded every 1 minute and down the line it will a huge data.  
i only need to keep the Docs say for past 10days, older i can delete. Could you suggest any way forward using curator plugin?

i tried using delete\_by\_query but vain.

> ```
> termQuery := NewRangeQuery("date").Lte("now-2d/d")
> put1, err := elasticSearchClient.DeleteByQuery().
> Index(index).
> Type(index).
> Query(termQuery).
> Do(elasticSearchContext)
> 
> ```

And mapping is as follow

> ```
> const cscfMappaing = `
> {
> "settings": {
> },
> "mapping": {
> "cscfcounter":{
> "properties":{
> "date": {
> "type": "date"
> },
> "NodeId":{
> "type":"keyword"
> },
> "NodeType":{
> "type":"keyword"
> },
> "State":{
> "type":"keyword"
> },
> "HaGroupId":{
> "type":"keyword"
> },
> "LbGroupId":{
> "type":"keyword"
> },
> "CpuAverageLoad":{
> "type":"keyword"
> },
> "MemUsed":{
> "type":"keyword"
> },
> "MemFree":{
> "type":"keyword"
> },
> "Static_limit":{
> "type":"keyword"
> }
> }
> }}}`
> 
> ```

---

<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 27, 2018, 7:11am UTC](https://discuss.elastic.co/t/deleting-old-docs-from-particular-index-using-curator-plugin/137546/4 "2018-06-27T07:11:33Z")

</div>

If you use time-based indices, e.g. an index per day or using the rollover API, you can simply drop complete indices using curator. This is much more efficient than deleting select documents from an index.

If you need to delete documents from within an index, delete-by-query is the way to go.

---

<div class="post-metadata">

**Author:** ![kish](https://avatars.discourse-cdn.com/v4/letter/k/71e660/32.png) [@kish](https://discuss.elastic.co/u/kish)\
**Post date:** [June 27, 2018, 7:19am UTC](https://discuss.elastic.co/t/deleting-old-docs-from-particular-index-using-curator-plugin/137546/5 "2018-06-27T07:19:07Z")

</div>

> [@Christian\_Dahlqvist](#):
>
> If you use time-based indices, e.g. an index per day or using the rollover API, you can simply drop complete indices using curator. This is much more efficient than deleting select documents from an index.

Could you kindly explain it(i am new to ES). You mean to say like, we need to define a indices which can load only certain amount of data(size) post which old data will be deleted and new new data will stored?

---

<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 27, 2018, 7:26am UTC](https://discuss.elastic.co/t/deleting-old-docs-from-particular-index-using-curator-plugin/137546/6 "2018-06-27T07:26:58Z")

</div>

[This blog post](https://www.elastic.co/blog/managing-time-based-indices-efficiently) describes how the rollover index API works and the benefits of it. [This blog post](https://www.elastic.co/blog/how-many-shards-should-i-have-in-my-elasticsearch-cluster) may also be useful.

---

<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 25, 2018, 7:26am UTC](https://discuss.elastic.co/t/deleting-old-docs-from-particular-index-using-curator-plugin/137546/7 "2018-07-25T07:26:59Z")

</div>

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