# Understand fuzzy and how it works

**URL:** <https://discuss.elastic.co/t/understand-fuzzy-and-how-it-works/14394>\
**Category:** Elasticsearch\
**Created:** [November 14, 2013, 1:52am UTC](https://discuss.elastic.co/t/understand-fuzzy-and-how-it-works/14394 "2013-11-14T01:52:52Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mohit\_Anchlia](https://avatars.discourse-cdn.com/v4/letter/m/848f3c/32.png) [@Mohit\_Anchlia](https://discuss.elastic.co/u/Mohit_Anchlia)\
**Post date:** [November 14, 2013, 1:52am UTC](https://discuss.elastic.co/t/understand-fuzzy-and-how-it-works/14394/1 "2013-11-14T01:52:52Z")

</div>

I indexed document with field customerID : user123 and user1234 and I ran  
below queries and got different results. I understand the concept of fuzzy  
but what I am interested in knowing is that how does elasticsearch store it  
internally that it's able to retrieve user1234 when I use a fuzzy query:

Match Query returns only user123.

[root@ip-10-80-140-242 ~]# ./match.e  
{  
"took" : 2,  
"timed\_out" : false,  
"\_shards" : {  
"total" : 1,  
"successful" : 1,  
"failed" : 0  
},  
"hits" : {  
"total" : 2,  
"max\_score" : 1.287682,  
"hits" : [ {  
"\_index" : "test1",  
"\_type" : "test",  
"\_id" : "3jreFivbT1CsrohoSjSDuw",  
"\_score" : 1.287682, "\_source" :  
{  
"productName":"sample",  
"customerID":"user123"  
}  
}, {  
"\_index" : "test1",  
"\_type" : "test",  
"\_id" : "\_Rfj0pPpSbWN5a72PVt1cQ",  
"\_score" : 1.287682, "\_source" :  
{  
"productName":"sample",  
"customerID":"user123"  
}  
} ]  
}  
}

Fuzzy Query with "text\_like\_this returns user1234:

## [root@ip-10-80-140-242 ~]# ./fuzzy.e { "took" : 3, "timed\_out" : false, "\_shards" : { "total" : 1, "successful" : 1, "failed" : 0 }, "hits" : { "total" : 4, "max\_score" : 0.9426194, "hits" : [{ "\_index" : "test1", "\_type" : "test", "\_id" : "3jreFivbT1CsrohoSjSDuw", "\_score" : 0.9426194, "\_source" : { "productName":"sample", "customerID":"user123" } }, { "\_index" : "test1", "\_type" : "test", "\_id" : "\_Rfj0pPpSbWN5a72PVt1cQ", "\_score" : 0.9426194, "\_source" : { "productName":"sample", "customerID":"user123" } }, { "\_index" : "test1", "\_type" : "test", "\_id" : "KzAHVe6fQNu9SsJVMVFK7A", "\_score" : 0.48092827, "\_source" : { "productName":"sample", "customerID":"user1234" } }, { "\_index" : "test1", "\_type" : "test", "\_id" : "nKAQjw0dSyqjFllDV9Z9iQ", "\_score" : 0.38474262, "\_source" : { "productName":"sample name", "customerID":"user1234" } }] } }

[root@ip-10-80-140-242 ~]# cat fuzzy.e

curl -XGET '[http://localhost:9200/test1/test/\_search?pretty=true](http://localhost:9200/test1/test/_search?pretty=true)' -d '{

"query" : {

"fuzzy\_like\_this" : {

"customerID" : {

"like\_text" : "user123"

}

}

}

}'

[root@ip-10-80-140-242 ~]# cat match.e

curl -XGET '[http://localhost:9200/test1/test/\_search?pretty=true](http://localhost:9200/test1/test/_search?pretty=true)' -d '{

"query" : {

"match" : {

"customerID" : "user123"

}

}

}'

--  
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:07am UTC](https://discuss.elastic.co/t/understand-fuzzy-and-how-it-works/14394/2 "2017-07-06T02:07:20Z")

</div>


