# Max docs per index limit

**URL:** <https://discuss.elastic.co/t/max-docs-per-index-limit/13367>\
**Category:** Elasticsearch\
**Created:** [August 28, 2013, 2:06pm UTC](https://discuss.elastic.co/t/max-docs-per-index-limit/13367 "2013-08-28T14:06:22Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Vadim\_Kisselmann](https://avatars.discourse-cdn.com/v4/letter/v/2bfe46/32.png) [@Vadim\_Kisselmann](https://discuss.elastic.co/u/Vadim_Kisselmann)\
**Post date:** [August 28, 2013, 2:06pm UTC](https://discuss.elastic.co/t/max-docs-per-index-limit/13367/1 "2013-08-28T14:06:22Z")

</div>

Hi folks,

is it possible to set a limit like max docs in index?  
And maybe to kick old docs when the limit is reached?

I want to use elasticsearch with an in-memory index for caching.  
My cache-docs get an TTL, but i want to limit the number of max docs in  
index too, because i don't know the real number of docs which should be  
cached.

Cheers and thanks  
Vadim

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![Ivan](https://avatars.discourse-cdn.com/v4/letter/i/df788c/32.png) [@Ivan](https://discuss.elastic.co/u/Ivan)\
**Post date:** [August 29, 2013, 6:51pm UTC](https://discuss.elastic.co/t/max-docs-per-index-limit/13367/2 "2013-08-29T18:51:01Z")

</div>

I believe Lucene imposes a limit of 2 billions documents per index, but  
that was using Lucene 3. Perhaps Lucene 4 offers more.

AFAIK, it is not possible to set an arbitrary limit in either elasticsearch  
or Lucene. Imposing a limit would be difficult since the total document  
count fluctuates greatly due to deleted documents and segment merging.

Cheers,

Ivan

On Wed, Aug 28, 2013 at 7:06 AM, Vadim Kisselmann [v.kisselmann@gmail.com](mailto:v.kisselmann@gmail.com)wrote:

> Hi folks,
> 
> is it possible to set a limit like max docs in index?  
> And maybe to kick old docs when the limit is reached?
> 
> I want to use elasticsearch with an in-memory index for caching.  
> My cache-docs get an TTL, but i want to limit the number of max docs in  
> index too, because i don't know the real number of docs which should be  
> cached.
> 
> Cheers and thanks  
> Vadim
> 
> --  
> You received this message because you are subscribed to the Google Groups  
> "elasticsearch" group.  
> To unsubscribe from this group and stop receiving emails from it, send an  
> email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![Vadim\_Kisselmann](https://avatars.discourse-cdn.com/v4/letter/v/2bfe46/32.png) [@Vadim\_Kisselmann](https://discuss.elastic.co/u/Vadim_Kisselmann)\
**Post date:** [August 30, 2013, 7:43am UTC](https://discuss.elastic.co/t/max-docs-per-index-limit/13367/3 "2013-08-30T07:43:10Z")

</div>

Hi Ivan,  
thanks for your answer.  
This arbitrary limit was my point. I searched for something like Capped  
Collections in mongoDB:

> **[Capped Collections — MongoDB Manual](https://www.mongodb.com/docs/manual/core/capped-collections/)**

So maybe i have to choose something different for my "cache".  
Cheers  
Vadim

Am Donnerstag, 29. August 2013 20:51:01 UTC+2 schrieb Ivan Brusic:

> I believe Lucene imposes a limit of 2 billions documents per index, but  
> that was using Lucene 3. Perhaps Lucene 4 offers more.
> 
> AFAIK, it is not possible to set an arbitrary limit in either  
> elasticsearch or Lucene. Imposing a limit would be difficult since the  
> total document count fluctuates greatly due to deleted documents and  
> segment merging.
> 
> Cheers,
> 
> Ivan
> 
> On Wed, Aug 28, 2013 at 7:06 AM, Vadim Kisselmann \<[v.kiss...@gmail.com](mailto:v.kiss...@gmail.com)\<javascript:\>
> 
> > wrote:
> 
> > Hi folks,
> > 
> > is it possible to set a limit like max docs in index?  
> > And maybe to kick old docs when the limit is reached?
> > 
> > I want to use elasticsearch with an in-memory index for caching.  
> > My cache-docs get an TTL, but i want to limit the number of max docs in  
> > index too, because i don't know the real number of docs which should be  
> > cached.
> > 
> > Cheers and thanks  
> > Vadim
> > 
> > --  
> > You received this message because you are subscribed to the Google Groups  
> > "elasticsearch" group.  
> > To unsubscribe from this group and stop receiving emails from it, send an  
> > email to [elasticsearc...@googlegroups.com](mailto:elasticsearc...@googlegroups.com) \<javascript:\>.  
> > For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![jprante](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jprante/32/44941_2.png) [@jprante](https://discuss.elastic.co/u/jprante)\
**Post date:** [September 1, 2013, 5:56pm UTC](https://discuss.elastic.co/t/max-docs-per-index-limit/13367/4 "2013-09-01T17:56:35Z")

</div>

An accounting plugin could be fairly easy to implement for limiting  
resources moved over the API, like number of shards, or volume of source,  
even dps or qps rate limits per index should be possible (traffic shaping).  
The idea is to save extra metadata from configuration in the cluster state,  
and each node checks index-based limits.

Not a great fan of it but I know that commercial offers may like to be  
based on rate limiting of all kinds.

Jörg

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<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, 2:18am UTC](https://discuss.elastic.co/t/max-docs-per-index-limit/13367/5 "2017-07-06T02:18:35Z")

</div>


