# What can I do to avoid exceeding the max\_clause\_count limit in match queries?

**URL:** <https://discuss.elastic.co/t/what-can-i-do-to-avoid-exceeding-the-max-clause-count-limit-in-match-queries/378574>\
**Category:** Elasticsearch\
**Created:** [May 27, 2025, 9:44am UTC](https://discuss.elastic.co/t/what-can-i-do-to-avoid-exceeding-the-max-clause-count-limit-in-match-queries/378574 "2025-05-27T09:44:00Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Zoree](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/zoree/32/142863_2.png) [@Zoree](https://discuss.elastic.co/u/Zoree)\
**Post date:** [May 27, 2025, 9:44am UTC](https://discuss.elastic.co/t/what-can-i-do-to-avoid-exceeding-the-max-clause-count-limit-in-match-queries/378574/1 "2025-05-27T09:44:00Z")

</div>

In our search, span\_near was previously used for distance search with term queries, but this led to a smaller sample than I would like, I moved the implementation to IntervalQuery with match, but now an error is being issued about reaching the max\_clause\_count limit, is it possible to fix this problem using the match query parameters?
