# TooManyClauses exception during rescore query

**URL:** https://discuss.elastic.co/t/toomanyclauses-exception-during-rescore-query/104312
**Category:** Elasticsearch
**Created:** [October 17, 2017, 10:57pm UTC](https://discuss.elastic.co/t/toomanyclauses-exception-during-rescore-query/104312 "2017-10-17T22:57:25Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![sharathr83](https://avatars.discourse-cdn.com/v4/letter/s/85f322/32.png) [@sharathr83](https://discuss.elastic.co/u/sharathr83)
#### Post date: [October 17, 2017, 10:57pm UTC](https://discuss.elastic.co/t/toomanyclauses-exception-during-rescore-query/104312/1 "2017-10-17T22:57:25Z")

</div>

Hi, I have a rescore query with a term filter with a ton of clauses (5000 plus). The query kinda looks like this:

```
 "query":{  
      "function_score":{  
         "query":{  
            "bool":{  
              ...
            }
         },
         "functions":[  
            {  
               "field_value_factor":{  
                  "field":"weight"
               }
            }
         ],
         "score_mode":"multiply"
      }
   },
   "rescore":{  
      "window_size":500,
      "query":{  
         "rescore_query":{  
            "function_score":{  
               "functions":[  
                  ...                  
                  {  
                     "filter":{  
                        "terms":{  
                           "my_id":[  
                              <ALL 5000+ ids>
                           ]
                        }
                     },
                     "weight":1000.0
                  }
               ],
               "score_mode":"multiply",
               "boost_mode":"multiply"
            }
         },
         "query_weight":1.0,
         "score_mode":"multiply",
         "rescore_query_weight":1
      }
   },

```

We just upgraded from ES 1.7 to ES 5.6.1. Was wondering if why this wasn't causing an issue in ES 1.7. Was the maxClausesCount greater in 1.7 (how much was it ? ) . Is there a way I can change my query to make sure this doesn't happen ? (The rescore query only seems to have a query rescorer. )

Thanks in advance !

---

<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: [November 14, 2017, 10:57pm UTC](https://discuss.elastic.co/t/toomanyclauses-exception-during-rescore-query/104312/2 "2017-11-14T22:57:58Z")

</div>

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