How minimum should match works in elasticsearch search

Hi Team,
I am tryining to use minimum should match on match_phrase search

I have to search for [STUCK] EcexuteThreads from the below line out of my data

<[STUCK] ExecuteThread: '3' for queue: 'weblogic.kernel.Default (self-tuning)

below is the query i am trying to search

{
"query": {
"bool": {
"minimum_should_match": 1,
"should": [
{
"match_phrase": {
"message":{
"query": "[STUCK] ExecuteThread"
}
}
}
]
}
}
}

when i am using minimum_should match to 1 i am getting 6 hits which are matched to my search query

But when i changed minimum_should_math to 2 and change the match phrase i am getting 0 hits, below is the changed query looks like

{
"query": {
"bool": {
"minimum_should_match": 2,
"should": [
{
"match_phrase": {
"message":{
"query": "[STUCK] ExecuteThread: '3' for "
}
}
}
]
}
}
}

As per my understanding when we use minimum_should-match to 2 , it tries to match atleast 2 terms in the filed ,but why it is not happening here where i am wrong?

Thanks
Ramya

I think the minimum_should_match is per optional clauses not terms, as you have only one clause in the example, that's why with the value 2 it returns nothing.

https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-minimum-should-match.html

Thanks for your Response !

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