# How minimum should match works in elasticsearch search

**URL:** <https://discuss.elastic.co/t/how-minimum-should-match-works-in-elasticsearch-search/194353>\
**Category:** Elasticsearch\
**Created:** [August 8, 2019, 5:31am UTC](https://discuss.elastic.co/t/how-minimum-should-match-works-in-elasticsearch-search/194353 "2019-08-08T05:31:22Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![RamyaGowda](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ramyagowda/32/27440_2.png) [@RamyaGowda](https://discuss.elastic.co/u/RamyaGowda)\
**Post date:** [August 8, 2019, 5:31am UTC](https://discuss.elastic.co/t/how-minimum-should-match-works-in-elasticsearch-search/194353/1 "2019-08-08T05:31:22Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![klof](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/klof/32/31590_2.png) [@klof](https://discuss.elastic.co/u/klof)\
**Post date:** [August 8, 2019, 12:38pm UTC](https://discuss.elastic.co/t/how-minimum-should-match-works-in-elasticsearch-search/194353/2 "2019-08-08T12:38:04Z")

</div>

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](https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-minimum-should-match.html)

---

<div class="post-metadata">

**Author:** ![RamyaGowda](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ramyagowda/32/27440_2.png) [@RamyaGowda](https://discuss.elastic.co/u/RamyaGowda)\
**Post date:** [August 19, 2019, 6:31am UTC](https://discuss.elastic.co/t/how-minimum-should-match-works-in-elasticsearch-search/194353/3 "2019-08-19T06:31:30Z")

</div>

Thanks for your Response !

---

<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:** [September 16, 2019, 6:31am UTC](https://discuss.elastic.co/t/how-minimum-should-match-works-in-elasticsearch-search/194353/4 "2019-09-16T06:31:31Z")

</div>

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