# Fuzzy & Exact Match Queries Using NEST API

**URL:** <https://discuss.elastic.co/t/fuzzy-exact-match-queries-using-nest-api/59993>\
**Category:** Elasticsearch\
**Created:** [September 7, 2016, 2:05pm UTC](https://discuss.elastic.co/t/fuzzy-exact-match-queries-using-nest-api/59993 "2016-09-07T14:05:58Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![luke305](https://avatars.discourse-cdn.com/v4/letter/l/ba8739/32.png) [@luke305](https://discuss.elastic.co/u/luke305)\
**Post date:** [September 7, 2016, 2:05pm UTC](https://discuss.elastic.co/t/fuzzy-exact-match-queries-using-nest-api/59993/1 "2016-09-07T14:05:58Z")

</div>

I'm using NEST v2.0 and trying to build a query such that when I search for a term that is in the index it will return that exact matches first along with possible fuzzy terms that are like the query but if I search for a term that's not in the index it will return fuzzy like terms or none if the initial query is way off.  
I read online that I should merge both my fuzzy and exact query using bool and should and use boost to give exact matches a higher priority if found so that it returns first on the page.The problem is when I search for a number it sometimes shows terms that are not even close or fuzzy terms before exact matches and when I search for fuzzy names(with one letter difference) no matches are found. How may I modify the query below to get desired results

* * *

```
 x => x.
          Query(q => q
              .Bool(b => b
                       .Should(s => s
                               .Fuzzy(c => c
                                 .Name("named_query")
                                 .Boost(1.1)
                                 .Field("_all")
                                 .Fuzziness(Fuzziness.Auto)
                                 .Value(query)
                                 .MaxExpansions(100)
                                 .PrefixLength(3)

                            )).Should(l => l
                                   .QueryString(y => y
                                         .DefaultField("_all")
                                         .Query(query)
                                         .Boost(10.0)
                                         ) )))
```

---

<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:** [July 5, 2017, 10:22pm UTC](https://discuss.elastic.co/t/fuzzy-exact-match-queries-using-nest-api/59993/2 "2017-07-05T22:22:03Z")

</div>


