# Setting index.max\_terms\_count has no effect?

**URL:** <https://discuss.elastic.co/t/setting-index-max-terms-count-has-no-effect/166532>\
**Category:** Elasticsearch\
**Created:** [January 31, 2019, 10:39am UTC](https://discuss.elastic.co/t/setting-index-max-terms-count-has-no-effect/166532 "2019-01-31T10:39:25Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![hariso](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/hariso/32/50668_2.png) [@hariso](https://discuss.elastic.co/u/hariso)\
**Post date:** [January 31, 2019, 10:39am UTC](https://discuss.elastic.co/t/setting-index-max-terms-count-has-no-effect/166532/1 "2019-01-31T10:39:25Z")

</div>

Hello!

I'm experimenting with index.max\_terms\_count. I've tried executing a terms query with over 65 536 terms in it, and I was surprised to see it actually gets executed, because I read the warning [here](https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-terms-query.html):

> Executing a Terms Query request with a lot of terms can be quite slow, as each additional term demands extra processing and memory. To safeguard against this, the maximum number of terms that can be used in a Terms Query both directly or through lookup has been limited to `65536` . This default maximum can be changed for a particular index with the index setting `index.max_terms_count` .

To test it further, I've tried setting index.max\_terms\_count to 2 or 3, and it still doesn't work the way I expect it to work. Can you please help me understand what am I doing (or understanding) wrong?

Steps:

1. Run ES using Docker:  
1.1.docker pull [docker.elastic.co/elasticsearch/elasticsearch:6.6.0](http://docker.elastic.co/elasticsearch/elasticsearch:6.6.0)  
1.2. docker run -p 9200:9200 -p 9300:9300 -e "discovery.type=single-node" [docker.elastic.co/elasticsearch/elasticsearch:6.6.0](http://docker.elastic.co/elasticsearch/elasticsearch:6.6.0)

2. Index document:  
curl -X POST [http://localhost:9200/twitter/\_doc/1](http://localhost:9200/twitter/_doc/1) -H 'Content-Type: application/json' -d '{  
"user" : "kimchy",  
"post\_date" : "2009-11-15T14:12:12",  
"message" : "trying out Elasticsearch",  
"tags": ["foo", "bar", "sun", "clouds"]  
}'

3. Change settings:  
curl -X PUT [http://localhost:9200/twitter/\_settings](http://localhost:9200/twitter/_settings) -H 'Content-Type: application/json' -d '{  
"index" : {  
"max\_terms\_count" : 2  
}  
}'

4. Verify settings are applied:  
`curl -X GET http://localhost:9200/twitter/_settings`

5. Perform a search:  
curl -X POST '[http://localhost:9200/twitter/\_search?pretty](http://localhost:9200/twitter/_search?pretty)' -H 'Content-Type: application/json' -d '{  
"query": {  
"terms" : { "tags" : ["sun", "cloudy", "yo", "hi", "hello"]}  
}  
}'

---

<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:** [February 28, 2019, 10:39am UTC](https://discuss.elastic.co/t/setting-index-max-terms-count-has-no-effect/166532/2 "2019-02-28T10:39:35Z")

</div>

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