# Feature Request: minimum\_should\_match support for Terms Set query

**URL:** <https://discuss.elastic.co/t/feature-request-minimum-should-match-support-for-terms-set-query/326374>\
**Category:** Elasticsearch\
**Created:** [February 23, 2023, 8:56pm UTC](https://discuss.elastic.co/t/feature-request-minimum-should-match-support-for-terms-set-query/326374 "2023-02-23T20:56:16Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![kulinsj](https://avatars.discourse-cdn.com/v4/letter/k/c0e974/32.png) [@kulinsj](https://discuss.elastic.co/u/kulinsj)\
**Post date:** [February 23, 2023, 8:56pm UTC](https://discuss.elastic.co/t/feature-request-minimum-should-match-support-for-terms-set-query/326374/1 "2023-02-23T20:56:16Z")

</div>

The Terms Set Query lets you match documents that have some minimum number of matches to a given array of input search terms. The minimum number of matches however can only be specified by referencing another field on the document or by using a script.

I don't understand why there isn't an option to just explicitly state a number at query time instead to be used as the minimum number of terms to match; this is what I need for my use case as I always need it to be 2, 3, or 4 depending on the query context, not depending on properties of the documents. Right now i'd have to either enable and use scripting which seems like overkill for something I want to just _be a number_, or index three extra dummy fields on _every_ document like

```auto
properties: {
  two: { type: integer },
  three: { type: integer },
  four: { type: integer },

```

and then always put the numbers 2, 3, and 4 in those dummy fields just so I can refer to them as the minimum\_should\_match\_field which also seems dumb to have to do.

As another workaround, what I'm currently doing is creating a bool query with a minimum\_should\_match of 2, 3, or 4 and mapping every input term to an individual `{ term: { field: value } } ` entry in the bool's should array but that stacks up _so much json_. The terms\_set query would be an ideal fit for my use case if it just supported the seemingly most basic option of specifying a number explicitly at query time for the minimum number of terms to match.

So, ultimately, this is a feature request to add that support to the Terms Set query. (but also if someone can think of a better way to achieve the behaviour I describe that would also be very appreciated)

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [February 23, 2023, 9:13pm UTC](https://discuss.elastic.co/t/feature-request-minimum-should-match-support-for-terms-set-query/326374/2 "2023-02-23T21:13:06Z")

</div>

Welcome to our community! 😃

Thanks for the idea, his would be better off on GitHub as a [feature request issue](https://github.com/elastic/elasticsearch/issues/new?assignees=&labels=%3Eenhancement%2Cneeds%3Atriage&template=feature-request.yml) 🙂

---

<div class="post-metadata">

**Author:** ![kulinsj](https://avatars.discourse-cdn.com/v4/letter/k/c0e974/32.png) [@kulinsj](https://discuss.elastic.co/u/kulinsj)\
**Post date:** [February 23, 2023, 9:32pm UTC](https://discuss.elastic.co/t/feature-request-minimum-should-match-support-for-terms-set-query/326374/3 "2023-02-23T21:32:36Z")

</div>

Thanks warkolm - I've gone ahead and [posted it up there](https://github.com/elastic/elasticsearch/issues/94095)

---

<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:** [March 23, 2023, 9:33pm UTC](https://discuss.elastic.co/t/feature-request-minimum-should-match-support-for-terms-set-query/326374/4 "2023-03-23T21:33:12Z")

</div>

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