# Fuzzy query doesn't return all the matching records

**URL:** <https://discuss.elastic.co/t/fuzzy-query-doesnt-return-all-the-matching-records/13813>\
**Category:** Elasticsearch\
**Created:** [October 1, 2013, 6:46am UTC](https://discuss.elastic.co/t/fuzzy-query-doesnt-return-all-the-matching-records/13813 "2013-10-01T06:46:09Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Yervand\_Aghababyan](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/yervand_aghababyan/32/2081_2.png) [@Yervand\_Aghababyan](https://discuss.elastic.co/u/Yervand_Aghababyan)\
**Post date:** [October 1, 2013, 6:46am UTC](https://discuss.elastic.co/t/fuzzy-query-doesnt-return-all-the-matching-records/13813/1 "2013-10-01T06:46:09Z")

</div>

I've posted this problem on stackoverflow and for several days no response  
has been given there. So I decided to rise the issue here as it is very  
important for my current project to have it solved.  
Link to the stackoverflow question:

> <https://stackoverflow.com/questions/19060544/elasticsearch-some-rows-missing-from-the-search-results>

Repost:

In my index I've got 40 rows with data like this:

| -name- | -surname- | -bdate string- | -creation date- |  
| leva | agabalyan | 19560901 | 2013-09-21T11:19:13.968Z |  
| leva | agabalyan | 19560901 | 2012-03-14T11:16:47.665Z |  
| leva | agabalyan | 19560901 | 2012-02-19T11:38:47.972Z |  
| leva | agabalyan | 19560901 | 2011-08-22T11:49:57.995Z |  
.....

All of these rows have the same name, surname and birth date string fields.  
The only difference is the creation date. In the real application there are  
significantly more fields/columns ( about 30 of them) but as you'll see  
they do not participate in the query. Also I've got significantly more rows  
like these outside the time range of my search query. So I suppose those  
shouldn't make a difference as well.

I also have a single rows like this one:

| -name- | -surname- | -bdate string- | -creation date- |  
| lyova | aghabalyan | 19560901 | 2013-06-27T11:19:33.345Z |

As you see the difference from the first table is in the name and surname  
fields. The name differs by 2 symbols and the surname by 1.

For searching I use this query:

{  
"query":{  
"bool":{  
"must":[{  
"fuzzy":{  
"registration.name":{  
"value":"lyova",  
"min\_similarity":"0.45"  
}}  
},  
{"fuzzy":{  
"registration.surname":{  
"value":"aghabalyan",  
"min\_similarity":"0.65"  
}}  
},  
{"term":{  
"registration.birthDateStr":"19560601"  
}},  
{"range":{  
"registration.created":{  
"from":"2011-01-01",  
"to":"2014-01-01"  
}  
}}  
],  
"must\_not":[],  
"should":[]}  
},  
"from":0,  
"size":50,  
"sort":[],  
"facets":{}  
}

This search query returns the 1 row containing lyova and 14 rows with leva.  
I don't understand why it is not returning the remaining 26 rows containing  
leva in them. The total number of hits is also 15 while it should have  
obviously been 41. It seems to me that I've encountered an elasticsearch  
bug here.

Also I'd like to note that IMO the problem is not in the additional search  
parameters I use(besides the fuzzy ones) because: If i search for lyova(sim:0.3)  
aghabalyan(sim:0.6) 19560601 dateRange I'm getting 15 results(1 lyova and  
14 leva) but If i search for leva(sim:0.3) agabalyan(sim:0.6) 19560601  
dateRange I'm getting 40 record(40 leva and 0 lyova). I believe I should be  
getting 41 results including the lyova record when searching forleva.

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<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 6, 2017, 2:14am UTC](https://discuss.elastic.co/t/fuzzy-query-doesnt-return-all-the-matching-records/13813/2 "2017-07-06T02:14:09Z")

</div>


