# Set the number of index segments for indexing

**URL:** https://discuss.elastic.co/t/set-the-number-of-index-segments-for-indexing/18463
**Category:** Elasticsearch
**Created:** [July 3, 2014, 2:04pm UTC](https://discuss.elastic.co/t/set-the-number-of-index-segments-for-indexing/18463 "2014-07-03T14:04:52Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Ophir\_Michaeli](https://avatars.discourse-cdn.com/v4/letter/o/9f8e36/32.png) [@Ophir\_Michaeli](https://discuss.elastic.co/u/Ophir_Michaeli)
#### Post date: [July 3, 2014, 2:04pm UTC](https://discuss.elastic.co/t/set-the-number-of-index-segments-for-indexing/18463/1 "2014-07-03T14:04:52Z")

</div>

Hi,

While optimizing it's pretty easy to determine the number of segments by  
executing Optimize command with max\_num\_segments parameter.  
My question is about indexing prior to optimizing.  
I checked the  
[http://www.elasticsearch.org/guide/en/elasticsearch/reference/0.90/index-modules-merge.html#tiered](http://www.elasticsearch.org/guide/en/elasticsearch/reference/0.90/index-modules-merge.html#tiered) section  
and I still couldn't find - how do I control the number of segments during  
indexing? Is there a simple way to tell to ES that I am willing to pay with  
indexing time and frequent merges but keep number of segments below 10, for  
example?

Thanks,  
Ophir

--  
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).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/3a57e027-1cd3-4578-9421-bf351e833dd4%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/3a57e027-1cd3-4578-9421-bf351e833dd4%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<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: [July 3, 2014, 4:15pm UTC](https://discuss.elastic.co/t/set-the-number-of-index-segments-for-indexing/18463/2 "2014-07-03T16:15:24Z")

</div>

It's a bit more complex. You can use the "segments\_per\_tier" to limit the  
number of segments to be created at a tier. Together with  
"max\_merge\_at\_once" you can control the amount of running merges.

Mike McCandless is the authority who can explain how the tiered merge  
policy works:

> **[Visualizing Lucene's segment merges](https://blog.mikemccandless.com/2011/02/visualizing-lucenes-segment-merges.html)**
>
> If you've ever wondered how Lucene picks segments to merge during indexing, it looks something like this: That video displays segment merges...

Jörg

On Thu, Jul 3, 2014 at 4:04 PM, Ophir Michaeli [ophirmichaeli@gmail.com](mailto:ophirmichaeli@gmail.com)  
wrote:

> Hi,
> 
> While optimizing it's pretty easy to determine the number of segments by  
> executing Optimize command with max\_num\_segments parameter.  
> My question is about indexing prior to optimizing.  
> I checked the  
> [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/en/elasticsearch/reference/0.90/index-modules-merge.html#tiered) section  
> and I still couldn't find - how do I control the number of segments during  
> indexing? Is there a simple way to tell to ES that I am willing to pay with  
> indexing time and frequent merges but keep number of segments below 10, for  
> example?
> 
> Thanks,  
> Ophir
> 
> --  
> 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).  
> To view this discussion on the web visit  
> [https://groups.google.com/d/msgid/elasticsearch/3a57e027-1cd3-4578-9421-bf351e833dd4%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/3a57e027-1cd3-4578-9421-bf351e833dd4%40googlegroups.com)  
> [https://groups.google.com/d/msgid/elasticsearch/3a57e027-1cd3-4578-9421-bf351e833dd4%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/3a57e027-1cd3-4578-9421-bf351e833dd4%40googlegroups.com?utm_medium=email&utm_source=footer)  
> .  
> For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

--  
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).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/CAKdsXoHqa7%2BBwppDPdgUoOmKjoDu9eByWHLb850R%2Bi3GF4NLTQ%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAKdsXoHqa7%2BBwppDPdgUoOmKjoDu9eByWHLb850R%2Bi3GF4NLTQ%40mail.gmail.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<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, 1:18am UTC](https://discuss.elastic.co/t/set-the-number-of-index-segments-for-indexing/18463/3 "2017-07-06T01:18:05Z")

</div>


