Setting index.max_terms_count has no effect?


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:

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?


  1. Run ES using Docker:
    1.1.docker pull
    1.2. docker run -p 9200:9200 -p 9300:9300 -e "discovery.type=single-node"

  2. Index document:
    curl -X POST 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 -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' -H 'Content-Type: application/json' -d '{
    "query": {
    "terms" : { "tags" : ["sun", "cloudy", "yo", "hi", "hello"]}

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