# How to Speed Up Elasticsearch bool.should Queries with Long Text Fields (Simulating max\_query\_terms in MLT)

**URL:** <https://discuss.elastic.co/t/how-to-speed-up-elasticsearch-bool-should-queries-with-long-text-fields-simulating-max-query-terms-in-mlt/378211>\
**Category:** Elasticsearch\
**Created:** [May 16, 2025, 8:30am UTC](https://discuss.elastic.co/t/how-to-speed-up-elasticsearch-bool-should-queries-with-long-text-fields-simulating-max-query-terms-in-mlt/378211 "2025-05-16T08:30:59Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Saleh\_AbuAli](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/saleh_abuali/32/141444_2.png) [@Saleh\_AbuAli](https://discuss.elastic.co/u/Saleh_AbuAli)\
**Post date:** [May 16, 2025, 8:30am UTC](https://discuss.elastic.co/t/how-to-speed-up-elasticsearch-bool-should-queries-with-long-text-fields-simulating-max-query-terms-in-mlt/378211/1 "2025-05-16T08:30:59Z")

</div>

When dealing with large text fields like `abstract` (which may contain **500+ terms** ), using a `bool.should` query with multiple `match` or `term` clauses can significantly impact performance due to the sheer number of terms Elasticsearch attempts to match.

In contrast, the `more_like_this` (MLT) query internally limits this via `max_query_terms`, which selects only the **top-N most significant terms** (default: 25, configurable). This makes MLT queries faster.  
Problem:

- we need to **avoid performance bottlenecks** caused by unbounded or very large token sets (e.g., matching 500+ terms from a full abstract).
- Unfortunately, `bool.should` doesn’t have a native equivalent of `max_query_terms` like MLT does.

Are there any recommended steps or parameters that can mimic `max_query_terms` for use in a `bool.should` query?  
our sample query

> POST /index1/\_search?typed\_keys=true { "\_source": { "includes": ["title", "doi", "publicationYear"] }, "query": { "bool": { "minimum\_should\_match": "1", "should": [{ "match": { "normalizedTitle": { "boost": 1.5, "analyzer": "stop", "auto\_generate\_synonyms\_phrase\_query": true, "fuzzy\_transpositions": true, "max\_expansions": 50, "minimum\_should\_match": "10%", "prefix\_length": 0, "query": "${title}" } } }, { "match": { "abstract": { "boost": 1.5, "analyzer": "stop", "minimum\_should\_match": "20%", "query": "${abstract}" } } }] } }, "rescore": [{ "query": { "rescore\_query": { "function\_score": { "boost\_mode": "multiply", "functions": [ { "script\_score": { "script": { "params": { "queryVector": "${paperVector}" }, "lang": "painless", "source": "doc['@vector'].size() == 0 ? 1 : (cosineSimilarity(params.queryVector, '@vector') + 1.0)" } } } ], "max\_boost": 3, "query": { "match\_all": {} }, "score\_mode": "multiply" } }, "query\_weight": 1, "rescore\_query\_weight": 1, "score\_mode": "multiply" }, "window\_size": 200 } ], "size": 98 }
