# A primary shard can store up to Integer.MAX\_VALUE -128 documents, how could es do if if the number of documents exceeds this value? thanks

**URL:** https://discuss.elastic.co/t/a-primary-shard-can-store-up-to-integer-max-value-128-documents-how-could-es-do-if-if-the-number-of-documents-exceeds-this-value-thanks/161143
**Category:** Elasticsearch
**Created:** [December 17, 2018, 12:29pm UTC](https://discuss.elastic.co/t/a-primary-shard-can-store-up-to-integer-max-value-128-documents-how-could-es-do-if-if-the-number-of-documents-exceeds-this-value-thanks/161143 "2018-12-17T12:29:51Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![zcx](https://avatars.discourse-cdn.com/v4/letter/z/e68b1a/32.png) [@zcx](https://discuss.elastic.co/u/zcx)
#### Post date: [December 17, 2018, 12:29pm UTC](https://discuss.elastic.co/t/a-primary-shard-can-store-up-to-integer-max-value-128-documents-how-could-es-do-if-if-the-number-of-documents-exceeds-this-value-thanks/161143/1 "2018-12-17T12:29:51Z")

</div>

as above. thanks

---

<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: [December 17, 2018, 12:33pm UTC](https://discuss.elastic.co/t/a-primary-shard-can-store-up-to-integer-max-value-128-documents-how-could-es-do-if-if-the-number-of-documents-exceeds-this-value-thanks/161143/2 "2018-12-17T12:33:11Z")

</div>

I believe the limit is just below 2 billion documents. If you have more data, use indices with multiple primary shards. You may also find that the optimal shard size for performance reasons may be lower than this limit.

---

<div class="post-metadata">

### Author: ![zcx](https://avatars.discourse-cdn.com/v4/letter/z/e68b1a/32.png) [@zcx](https://discuss.elastic.co/u/zcx)
#### Post date: [December 17, 2018, 12:37pm UTC](https://discuss.elastic.co/t/a-primary-shard-can-store-up-to-integer-max-value-128-documents-how-could-es-do-if-if-the-number-of-documents-exceeds-this-value-thanks/161143/3 "2018-12-17T12:37:50Z")

</div>

emm. I know what you mean, but if I set 1 shard for the index at the beginning ,and as time goes by, the number of documents exceeds this value?

---

<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: [December 17, 2018, 12:41pm UTC](https://discuss.elastic.co/t/a-primary-shard-can-store-up-to-integer-max-value-128-documents-how-could-es-do-if-if-the-number-of-documents-exceeds-this-value-thanks/161143/4 "2018-12-17T12:41:19Z")

</div>

Then you need to change to a large number of shards per index. If you are on a recent version and added the required settings at index creation time, you can use the [split index API](https://www.elastic.co/guide/en/elasticsearch/reference/6.5/indices-split-index.html). Otherwise you most likely need to reindex into a new index with a larger number of primary shards. The easiest way might be to create an index with a number of primary shards already at the outset to account for the growth.

---

<div class="post-metadata">

### Author: ![zcx](https://avatars.discourse-cdn.com/v4/letter/z/e68b1a/32.png) [@zcx](https://discuss.elastic.co/u/zcx)
#### Post date: [December 17, 2018, 12:46pm UTC](https://discuss.elastic.co/t/a-primary-shard-can-store-up-to-integer-max-value-128-documents-how-could-es-do-if-if-the-number-of-documents-exceeds-this-value-thanks/161143/5 "2018-12-17T12:46:51Z")

</div>

ok, i see . 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: [January 14, 2019, 12:47pm UTC](https://discuss.elastic.co/t/a-primary-shard-can-store-up-to-integer-max-value-128-documents-how-could-es-do-if-if-the-number-of-documents-exceeds-this-value-thanks/161143/6 "2019-01-14T12:47:00Z")

</div>

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