New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Explicit minimum_should_match number support for Terms Set Query #94095
Comments
Pinging @elastic/es-search (Team:Search) |
Is the accepted answer on this link useful for you? |
That's pretty much exactly what I describe as the alternative I'm using now in my original post: using a bool query with should and n |
The main concern I have is around optimizations. We attempt to optimize the Any |
To be clear, I'm talking about the Terms Set query which is distinct from the Terms Query. The Terms Set query already supports a minimum match specification in two other formats - I don't see how this would be any less optimized than those? If anything it should be more performant than the existingly supported |
Hello @javanna @benwtrent, can I pick it up? My understanding is that a new parameter is needed in the terms set query to specify what're the minimum matches in order to return a document. |
hi @Kiriakos1998 sounds good to me. |
Hello @javanna @benwtrent , i have opened a pull request. |
Hey @javanna @benwtrent , Is the currently opened pull request still in consideration or can I pick up this task? I am a first time contributor. |
@Utsavk we should allow @Kiriakos1998 to finish their work. I added a review there. Thank for your interest in the issue! |
Support minimum_should_match for terms_set query. Closes(#94095) --------- Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com> Co-authored-by: Benjamin Trent <ben.w.trent@gmail.com>
Support minimum_should_match for terms_set query. Closes(elastic#94095) --------- Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com> Co-authored-by: Benjamin Trent <ben.w.trent@gmail.com>
If the issues is fixed can we mark this as closed? |
Good point, auto close didn't work here. |
Hi @benwtrent, may I ask which version we can use feature? |
Description
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 have a use case where I need to be able to specify the minimum number of terms to match at query time, agnostic of documents so the
minimum_should_match_field
is not useful. Further, since I know I need to match a minimum of exactly, say, 3 terms, it seems like overkill to have to enable and using scripting (as in the use ofminimum_should_match_script
) to just return a static number.Today as an alternative, I'm instead using a Bool Query with a
minimum_should_match
accepting my explicit number and all of my input search terms mapping to an array of individual{ term: { field: value } }
entries in theshould
array of the bool. However, this is very json-inefficient, especially when I am making queries with many (possibly thousands) of terms in my query.I was so happy to find the Terms Set query as a leaner, more specialized alternative to my massive
should
array but was then very surprised that there was no query-time input for the minimum match count (outside scripting).TL;DR: Terms Set query should support a third possible top-level parameter for specifying the minimum number of terms to match which simply accepts a number, like
minimum_should_match
The text was updated successfully, but these errors were encountered: