# Elasticsearch is using more and more space on my disc

**URL:** <https://discuss.elastic.co/t/elasticsearch-is-using-more-and-more-space-on-my-disc/5134>\
**Category:** Elasticsearch\
**Created:** [August 12, 2011, 8:39am UTC](https://discuss.elastic.co/t/elasticsearch-is-using-more-and-more-space-on-my-disc/5134 "2011-08-12T08:39:37Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![erlo](https://avatars.discourse-cdn.com/v4/letter/e/f07891/32.png) [@erlo](https://discuss.elastic.co/u/erlo)\
**Post date:** [August 12, 2011, 8:39am UTC](https://discuss.elastic.co/t/elasticsearch-is-using-more-and-more-space-on-my-disc/5134/1 "2011-08-12T08:39:37Z")

</div>

Hello,

I'm using elasticsearch 0.16.2 on a single node. I'm using it to store  
almost the same number of document at all time, which are actually a  
big event list of the last 7 days.  
Every night I purge the database using something like:

curl -XDELETE 'myserver/\_query' -d '{  
"range" : { "date" : { "lte": "'2011-08-05T00:00:00" } }  
}'

Then, I run an optimize query: something like :

curl -XPOST 'myserver/\_optimize' -d '{  
"max\_num\_segments" : 1  
}

Every seems to work, BUT the data directory of elasticsearch is still  
increasing. Is anyone can tell how can I do my document rotation  
without always increasing the used space ?

Thanks !

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [August 12, 2011, 8:55am UTC](https://discuss.elastic.co/t/elasticsearch-is-using-more-and-more-space-on-my-disc/5134/2 "2011-08-12T08:55:05Z")

</div>

Hi Erwan,

You should consider using index aliases for that need.

Create an index each day with the name myserver\_yyyymmdd  
Create an alias on each daily index called myserver

Then you can make your searches on /myserver

When you have to purge one entire day, just drop the indexmyserver\_yyyymmdd  
It will take some milliseconds and will really clean your filesystem

Hope this helps  
David.

Le 12 août 2011 à 10:39, erlo [erwan.loaec@cgin.fr](mailto:erwan.loaec@cgin.fr) a écrit :

> Hello,
> 
> I'm using elasticsearch 0.16.2 on a single node. I'm using it to store  
> almost the same number of document at all time, which are actually a  
> big event list of the last 7 days.  
> Every night I purge the database using something like:
> 
> curl -XDELETE 'myserver/\_query' -d '{  
> "range" : { "date" : { "lte": "'2011-08-05T00:00:00" } }  
> }'
> 
> Then, I run an optimize query: something like :
> 
> curl -XPOST 'myserver/\_optimize' -d '{  
> "max\_num\_segments" : 1  
> }
> 
> Every seems to work, BUT the data directory of elasticsearch is still  
> increasing. Is anyone can tell how can I do my document rotation  
> without always increasing the used space ?
> 
> Thanks !

---

<div class="post-metadata">

**Author:** ![erlo](https://avatars.discourse-cdn.com/v4/letter/e/f07891/32.png) [@erlo](https://discuss.elastic.co/u/erlo)\
**Post date:** [August 12, 2011, 9:17am UTC](https://discuss.elastic.co/t/elasticsearch-is-using-more-and-more-space-on-my-disc/5134/3 "2011-08-12T09:17:21Z")

</div>

Thank you for answer. I will seriously take a look about this in the  
future improvement of my application. But, for the moment I have to  
keep my current design...  
But I think there should have a solution to "clean" the data  
filesystem, to reduce size on my disc ?

On 12 août, 10:55, "[da...@pilato.fr](mailto:da...@pilato.fr)" [da...@pilato.fr](mailto:da...@pilato.fr) wrote:

> Hi Erwan,
> 
> You should consider using index aliases for that need.
> 
> Create an index each day with the name myserver\_yyyymmdd  
> Create an alias on each daily index called myserver
> 
> Then you can make your searches on /myserver
> 
> When you have to purge one entire day, just drop the indexmyserver\_yyyymmdd  
> It will take some milliseconds and will really clean your filesystem
> 
> Hope this helps  
> David.
> 
> Le 12 août 2011 à 10:39, erlo [erwan.lo...@cgin.fr](mailto:erwan.lo...@cgin.fr) a écrit :
> 
> > Hello,
> 
> > I'm using elasticsearch 0.16.2 on a single node. I'm using it to store  
> > almost the same number of document at all time, which are actually a  
> > big event list of the last 7 days.  
> > Every night I purge the database using something like:
> 
> > curl -XDELETE 'myserver/\_query' -d '{  
> > "range" : { "date" : { "lte": "'2011-08-05T00:00:00" } }  
> > }'
> 
> > Then, I run an optimize query: something like :
> 
> > curl -XPOST 'myserver/\_optimize' -d '{  
> > "max\_num\_segments" : 1  
> > }
> 
> > Every seems to work, BUT the data directory of elasticsearch is still  
> > increasing. Is anyone can tell how can I do my document rotation  
> > without always increasing the used space ?
> 
> > Thanks !

---

<div class="post-metadata">

**Author:** ![kimchy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kimchy/32/44952_2.png) [@kimchy](https://discuss.elastic.co/u/kimchy)\
**Post date:** [August 12, 2011, 9:47am UTC](https://discuss.elastic.co/t/elasticsearch-is-using-more-and-more-space-on-my-disc/5134/4 "2011-08-12T09:47:23Z")

</div>

The max\_num\_segments is a request parameter:  
[Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/reference/api/admin-indices-optimize.html),  
Meaning, you ened to run: /\_optimize?max\_num\_segments=1. In 0.16.2 make sure  
to flush before as well.

On Fri, Aug 12, 2011 at 12:17 PM, erlo [erwan.loaec@cgin.fr](mailto:erwan.loaec@cgin.fr) wrote:

> Thank you for answer. I will seriously take a look about this in the  
> future improvement of my application. But, for the moment I have to  
> keep my current design...  
> But I think there should have a solution to "clean" the data  
> filesystem, to reduce size on my disc ?
> 
> On 12 août, 10:55, "[da...@pilato.fr](mailto:da...@pilato.fr)" [da...@pilato.fr](mailto:da...@pilato.fr) wrote:
> 
> > Hi Erwan,
> > 
> > You should consider using index aliases for that need.
> > 
> > Create an index each day with the name myserver\_yyyymmdd  
> > Create an alias on each daily index called myserver
> > 
> > Then you can make your searches on /myserver
> > 
> > When you have to purge one entire day, just drop the  
> > indexmyserver\_yyyymmdd  
> > It will take some milliseconds and will really clean your filesystem
> > 
> > Hope this helps  
> > David.
> > 
> > Le 12 août 2011 à 10:39, erlo [erwan.lo...@cgin.fr](mailto:erwan.lo...@cgin.fr) a écrit :
> > 
> > > Hello,
> > 
> > > I'm using elasticsearch 0.16.2 on a single node. I'm using it to store  
> > > almost the same number of document at all time, which are actually a  
> > > big event list of the last 7 days.  
> > > Every night I purge the database using something like:
> > 
> > > curl -XDELETE 'myserver/\_query' -d '{  
> > > "range" : { "date" : { "lte": "'2011-08-05T00:00:00" } }  
> > > }'
> > 
> > > Then, I run an optimize query: something like :
> > 
> > > curl -XPOST 'myserver/\_optimize' -d '{  
> > > "max\_num\_segments" : 1  
> > > }
> > 
> > > Every seems to work, BUT the data directory of elasticsearch is still  
> > > increasing. Is anyone can tell how can I do my document rotation  
> > > without always increasing the used space ?
> > 
> > > Thanks !

---

<div class="post-metadata">

**Author:** ![erlo](https://avatars.discourse-cdn.com/v4/letter/e/f07891/32.png) [@erlo](https://discuss.elastic.co/u/erlo)\
**Post date:** [August 12, 2011, 2:41pm UTC](https://discuss.elastic.co/t/elasticsearch-is-using-more-and-more-space-on-my-disc/5134/5 "2011-08-12T14:41:39Z")

</div>

Thanks a lot !!  
My problem was here.

Shay Banon wrote:

> The max\_num\_segments is a request  
> parameter: [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/reference/api/admin-indices-optimize.html),  
> Meaning, you ened to run: /\_optimize?max\_num\_segments=1. In 0.16.2 make  
> sure to flush before as well.
> 
> On Fri, Aug 12, 2011 at 12:17 PM, erlo \<[erwan.loaec@cgin.fr](mailto:erwan.loaec@cgin.fr)  
> [mailto:erwan.loaec@cgin.fr](mailto:erwan.loaec@cgin.fr)\> wrote:
> 
> ```
> Thank you for answer. I will seriously take a look about this in the
> future improvement of my application. But, for the moment I have to
> keep my current design...
> But I think there should have a solution to "clean" the data
> filesystem, to reduce size on my disc ?
> 
> On 12 août, 10:55, "da...@pilato.fr <mailto:da...@pilato.fr>"
> <da...@pilato.fr <mailto:da...@pilato.fr>> wrote:
> > Hi Erwan,
> >  
> >  
> > You should consider using index aliases for that need.
> >  
> > Create an index each day with the name myserver_yyyymmdd
> > Create an alias on each daily index called myserver
> >  
> > Then you can make your searches on /myserver
> >  
> > When you have to purge one entire day, just drop the
> indexmyserver_yyyymmdd
> > It will take some milliseconds and will really clean your filesystem
> >  
> >  
> > Hope this helps
> > David. 
> >  
> >  
> >  
> >
> > Le 12 août 2011 à 10:39, erlo <erwan.lo...@cgin.fr
> <mailto:erwan.lo...@cgin.fr>> a écrit :
> >
> > > Hello,
> >
> > > I'm using elasticsearch 0.16.2 on a single node. I'm using it
> to store
> > > almost the same number of document at all time, which are
> actually a
> > > big event list of the last 7 days.
> > > Every night I purge the database using something like:
> >
> > > curl -XDELETE 'myserver/_query' -d '{
> > > "range" : { "date" : { "lte": "'2011-08-05T00:00:00" } }
> > > }'
> >
> > > Then, I run an optimize query: something like :
> >
> > > curl -XPOST 'myserver/_optimize' -d '{
> > > "max_num_segments" : 1
> > > }
> >
> > > Every seems to work, BUT the data directory of elasticsearch is
> still
> > > increasing. Is anyone can tell how can I do my document rotation
> > > without always increasing the used space ?
> >
> > > Thanks !
> 
> ```

---

<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 6, 2017, 3:57am UTC](https://discuss.elastic.co/t/elasticsearch-is-using-more-and-more-space-on-my-disc/5134/6 "2017-07-06T03:57:18Z")

</div>


