# My Requirement is If Match happend then I don't want check remaining match cases of Query because of it will decrease search performance

**URL:** <https://discuss.elastic.co/t/my-requirement-is-if-match-happend-then-i-dont-want-check-remaining-match-cases-of-query-because-of-it-will-decrease-search-performance/132552>\
**Category:** Elasticsearch\
**Created:** [May 19, 2018, 6:01am UTC](https://discuss.elastic.co/t/my-requirement-is-if-match-happend-then-i-dont-want-check-remaining-match-cases-of-query-because-of-it-will-decrease-search-performance/132552 "2018-05-19T06:01:00Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sekhar1](https://avatars.discourse-cdn.com/v4/letter/s/e19adc/32.png) [@Sekhar1](https://discuss.elastic.co/u/Sekhar1)\
**Post date:** [May 19, 2018, 6:01am UTC](https://discuss.elastic.co/t/my-requirement-is-if-match-happend-then-i-dont-want-check-remaining-match-cases-of-query-because-of-it-will-decrease-search-performance/132552/1 "2018-05-19T06:01:00Z")

</div>

Query : {"query":{"bool":{"should":[{"match":{"4":{"query":"kavana","\_name":"4.WordMatch"}}},{"match":{"4.exactMatch":{"query":"kavana","\_name":"4.exactMatch"}}}],"minimum\_should\_match":1}}}

Output of Match Cases:

"matched\_queries": ["4.WordMatch", "4.exactMatch"]

My Requirement is If Match happend then I don't want check remaining match cases of Query because of it will decrease search performance but it will increase documents count. Think as Should as IF condition and match case as Condition .Suppose each Condition between OR mean if First condition true mean it will entry into IF condition or checking remaining condition.Same behaviour I am Expecting

Sample Query :

{"query":{"bool":{"should":[{"match":{"4":{"query":"kavana","\_name":"4.WordMatch"}}},{"match":{"4.exactMatch":{"query":"kavana","\_name":"4.exactMatch"}}}],"minimum\_should\_match":1}}}

Sample OutOut :

"matched\_queries": ["4.WordMatch"]

or  
"matched\_queries": ["4.exactMatch"]

---

<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:** [May 20, 2018, 8:22am UTC](https://discuss.elastic.co/t/my-requirement-is-if-match-happend-then-i-dont-want-check-remaining-match-cases-of-query-because-of-it-will-decrease-search-performance/132552/2 "2018-05-20T08:22:03Z")

</div>

There's no way to do this that would make sense, it needs to query multiple documents to find out the relevant documents and then find the one that is _most_ relevant.

What exactly do you want this for?

---

<div class="post-metadata">

**Author:** ![Sekhar1](https://avatars.discourse-cdn.com/v4/letter/s/e19adc/32.png) [@Sekhar1](https://discuss.elastic.co/u/Sekhar1)\
**Post date:** [May 21, 2018, 4:19am UTC](https://discuss.elastic.co/t/my-requirement-is-if-match-happend-then-i-dont-want-check-remaining-match-cases-of-query-because-of-it-will-decrease-search-performance/132552/3 "2018-05-21T04:19:02Z")

</div>

I want to terminate search query if match query matched happend on should.

Example : If(condition1 ||condition2 || condition3 || condition4)  
explaination: condition1 is true then it will entry into if block.It will not check remaining condition 2 to condition 4

should(match1 || match2 || match3 || match4)  
Explaination : match1 query matched mean I don't want check remaining match cases.

I don't want more document's .I want know match happend or not.that it

---

<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:** [June 18, 2018, 4:19am UTC](https://discuss.elastic.co/t/my-requirement-is-if-match-happend-then-i-dont-want-check-remaining-match-cases-of-query-because-of-it-will-decrease-search-performance/132552/4 "2018-06-18T04:19:06Z")

</div>

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