# DSL query for "exact" match in fuzzy searches

**URL:** <https://discuss.elastic.co/t/dsl-query-for-exact-match-in-fuzzy-searches/203026>\
**Category:** Elasticsearch\
**Created:** [October 10, 2019, 12:54pm UTC](https://discuss.elastic.co/t/dsl-query-for-exact-match-in-fuzzy-searches/203026 "2019-10-10T12:54:10Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Luigi\_Bardelli](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/luigi_bardelli/32/55691_2.png) [@Luigi\_Bardelli](https://discuss.elastic.co/u/Luigi_Bardelli)\
**Post date:** [October 10, 2019, 12:54pm UTC](https://discuss.elastic.co/t/dsl-query-for-exact-match-in-fuzzy-searches/203026/1 "2019-10-10T12:54:10Z")

</div>

(newbie here, I hope it's the correct forum)

Hi all,  
I am using elastic to do some fuzzy searches on few indexed text fields, so far so good.  
My question: I would like to limit the results as follows:

Let's say that the user searches "mytext":

1. if "mytext" is not an exact match on any indexed field --\> go for the usual fuzzy search
2. if on the contrary "mytext" is found _exactly_ in one field --\> display only that records and skip all the "fuzzy" ones

I have read the multi\_match docs but I have had no luck... Anyone willing to help?  
Many thanks!  
Luigi

---

<div class="post-metadata">

**Author:** ![Mark\_Harwood](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mark_harwood/32/10538_2.png) [@Mark\_Harwood](https://discuss.elastic.co/u/Mark_Harwood)\
**Post date:** [October 10, 2019, 2:07pm UTC](https://discuss.elastic.co/t/dsl-query-for-exact-match-in-fuzzy-searches/203026/2 "2019-10-10T14:07:04Z")

</div>

You would have to implement this "retry if no matches" logic in your client application.

Elasticsearch is designed to be a distributed system so the query execution logic on one node doesn't know if another node might have found a match for `mytext` or not.

Your client could issue one [msearch](https://www.elastic.co/guide/en/elasticsearch/reference/7.4/search-multi-search.html) request containing a strict and lax version of the searches and only use the lax results if the strict result was empty. That might be more expensive (needlessly running some lax searches) but would mean your client makes only one request.

---

<div class="post-metadata">

**Author:** ![Luigi\_Bardelli](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/luigi_bardelli/32/55691_2.png) [@Luigi\_Bardelli](https://discuss.elastic.co/u/Luigi_Bardelli)\
**Post date:** [October 10, 2019, 2:17pm UTC](https://discuss.elastic.co/t/dsl-query-for-exact-match-in-fuzzy-searches/203026/3 "2019-10-10T14:17:26Z")

</div>

many thanks, msearch seems exactly what I need  
Luigi

---

<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:** [November 7, 2019, 2:17pm UTC](https://discuss.elastic.co/t/dsl-query-for-exact-match-in-fuzzy-searches/203026/4 "2019-11-07T14:17:42Z")

</div>

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