Feature Request: minimum_should_match support for Terms Set query

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

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)

Welcome to our community! :smiley:

Thanks for the idea, his would be better off on GitHub as a feature request issue :slight_smile:

Thanks warkolm - I've gone ahead and posted it up there

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