# Setting number of segments to 1

**URL:** <https://discuss.elastic.co/t/setting-number-of-segments-to-1/75198>\
**Category:** Elasticsearch\
**Created:** [February 15, 2017, 1:08pm UTC](https://discuss.elastic.co/t/setting-number-of-segments-to-1/75198 "2017-02-15T13:08:46Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![elastic\_user\_0193](https://avatars.discourse-cdn.com/v4/letter/e/e495f1/32.png) [@elastic\_user\_0193](https://discuss.elastic.co/u/elastic_user_0193)\
**Post date:** [February 15, 2017, 1:08pm UTC](https://discuss.elastic.co/t/setting-number-of-segments-to-1/75198/1 "2017-02-15T13:08:46Z")

</div>

Hi all,

I am running a query which is heavy on computing. When performing load testing with a decent load, we see that the ES query takes almost 700 - 800 ms to execute.

Hence, we decided to use the optimize API in ES and set the number of segments to 1. I have given this command to set it

> $ curl -XPOST '[http://localhost:9200/your-index/\_optimize?max\_num\_segments=1](http://localhost:9200/your-index/_optimize?max_num_segments=1)'

But as and when more documents are added and the index is updated, ES defaults to creating more number of segments and the merging process happens.

Our configuration:  
2 Core EC2 instance with 8GB ram.  
ES Nodes: 3  
Shards per index: 2  
Number of replicas: 1  
Size of the documents in index: 0.1 Million

Is there any way to permanently set the number of segments to 1?

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [February 15, 2017, 9:16pm UTC](https://discuss.elastic.co/t/setting-number-of-segments-to-1/75198/2 "2017-02-15T21:16:41Z")

</div>

> [@elastic\_user\_0193](#):
>
> Is there any way to permanently set the number of segments to 1?

No, segments are automatically created by Lucene.

---

<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:** [March 15, 2017, 9:17pm UTC](https://discuss.elastic.co/t/setting-number-of-segments-to-1/75198/3 "2017-03-15T21:17:30Z")

</div>

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