# Fuzzy query

**URL:** https://discuss.elastic.co/t/fuzzy-query/14831
**Category:** Elasticsearch
**Created:** [December 12, 2013, 2:22am UTC](https://discuss.elastic.co/t/fuzzy-query/14831 "2013-12-12T02:22:11Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Linlin\_Fu](https://avatars.discourse-cdn.com/v4/letter/l/eb8c5e/32.png) [@Linlin\_Fu](https://discuss.elastic.co/u/Linlin_Fu)
#### Post date: [December 12, 2013, 2:22am UTC](https://discuss.elastic.co/t/fuzzy-query/14831/1 "2013-12-12T02:22:11Z")

</div>

Followed this [https://github.com/elasticsearch/elasticsearch](https://github.com/elasticsearch/elasticsearch) guide,  
setup elasticSearch and the twitter like information.

As shown below, fuzzy search { "user": "kimc" } can get expected result,  
but fuzzy search { "user": "kim" } cannot get results.

What is the cause?

Thank you.

_curl -XGET '[http://localhost:9200/twitter/tweet/\_search?pretty=true](http://localhost:9200/twitter/tweet/_search?pretty=true)' -d '_  
\*{ \*

- "query" : { \*
- 

```
   "fuzzy" : { "user": "kimc" }*

```

- } \*  
_}'_  
{  
"took" : 3,  
"timed\_out" : false,  
"\_shards" : {  
"total" : 5,  
"successful" : 5,  
"failed" : 0  
},  
"hits" : {  
"total" : 2,  
"max\_score" : 1.0,  
"hits" : [ {  
"\_index" : "twitter",  
"\_type" : "tweet",  
"\_id" : "2",  
"\_score" : 1.0, "\_source" :  
{  
"user": "kimchy",  
"postDate": "2009-11-15T14:12:12",  
"message": "Another tweet, will it be indexed?"  
}  
}, {  
"\_index" : "twitter",  
"\_type" : "tweet",  
"\_id" : "1",  
"\_score" : 0.30685282, "\_source" :  
{  
"user": "kimchy",  
"postDate": "2009-11-15T13:12:00",  
"message": "Trying out Elastic Search, so far so good?"  
}  
} ]  
}  
}

_curl -XGET '[http://localhost:9200/twitter/tweet/\_search?pretty=true](http://localhost:9200/twitter/tweet/_search?pretty=true)' -d '_  
\*{ \*

- "query" : { \*
- 

```
   "fuzzy" : { "user": "kim" }*

```

- } \*  
_}'_  
{  
"took" : 2,  
"timed\_out" : false,  
"\_shards" : {  
"total" : 5,  
"successful" : 5,  
"failed" : 0  
},  
"hits" : {  
"total" : 0,  
"max\_score" : null,  
"hits" : []  
}  
}  
linlinfu-mac:~ linlinfu$

--  
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).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/5f543af7-7758-459f-b5c7-c1f856690b72%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/5f543af7-7758-459f-b5c7-c1f856690b72%40googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

### Author: ![Andrew\_Cholakian\_2](https://avatars.discourse-cdn.com/v4/letter/a/7ab992/32.png) [@Andrew\_Cholakian\_2](https://discuss.elastic.co/u/Andrew_Cholakian_2)
#### Post date: [December 12, 2013, 3:50am UTC](https://discuss.elastic.co/t/fuzzy-query/14831/2 "2013-12-12T03:50:11Z")

</div>

Hi, the reason is that fuzzy queries have a configurable edit distance. The  
max distance is 2. The edit distance between "kim" and "kimchy" is 3 (since  
3 characters must be inserted). Lucene (the underlying search engine of  
elasticsearch / SOLR) cannot efficiently search words with an edit distance

> 1. You may want to try either ngrams  
> [http://exploringelasticsearch.com/book/searching-natural-language/searching-non-word-text.html](http://exploringelasticsearch.com/book/searching-natural-language/searching-non-word-text.html)(as  
> in this example) or using wildcards[http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/query-dsl-wildcard-query.html](http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/query-dsl-wildcard-query.html)  
> .

Please see the Fuzzy documentation for more  
detail: [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/query-dsl-fuzzy-query.html)

On Wednesday, December 11, 2013 6:22:11 PM UTC-8, Linlin Fu wrote:

> Followed this [GitHub - elastic/elasticsearch: Free and Open, Distributed, RESTful Search Engine](https://github.com/elasticsearch/elasticsearch) guide,  
> setup elasticSearch and the twitter like information.
> 
> As shown below, fuzzy search { "user": "kimc" } can get expected result,  
> but fuzzy search { "user": "kim" } cannot get results.
> 
> What is the cause?
> 
> Thank you.
> 
> _curl -XGET '[http://localhost:9200/twitter/tweet/\_search?pretty=true](http://localhost:9200/twitter/tweet/_search?pretty=true)  
> [http://localhost:9200/twitter/tweet/\_search?pretty=true](http://localhost:9200/twitter/tweet/_search?pretty=true)' -d '_  
> \*{ \*
> 
> - "query" : { \*
> - 
> 
> ```
> "fuzzy" : { "user": "kimc" }*
> 
> ```
> 
> - } \*  
> _}'_  
> {  
> "took" : 3,  
> "timed\_out" : false,  
> "\_shards" : {  
> "total" : 5,  
> "successful" : 5,  
> "failed" : 0  
> },  
> "hits" : {  
> "total" : 2,  
> "max\_score" : 1.0,  
> "hits" : [ {  
> "\_index" : "twitter",  
> "\_type" : "tweet",  
> "\_id" : "2",  
> "\_score" : 1.0, "\_source" :  
> {  
> "user": "kimchy",  
> "postDate": "2009-11-15T14:12:12",  
> "message": "Another tweet, will it be indexed?"  
> }  
> }, {  
> "\_index" : "twitter",  
> "\_type" : "tweet",  
> "\_id" : "1",  
> "\_score" : 0.30685282, "\_source" :  
> {  
> "user": "kimchy",  
> "postDate": "2009-11-15T13:12:00",  
> "message": "Trying out Elastic Search, so far so good?"  
> }  
> } ]  
> }  
> }
> 
> _curl -XGET '[http://localhost:9200/twitter/tweet/\_search?pretty=true](http://localhost:9200/twitter/tweet/_search?pretty=true)  
> [http://localhost:9200/twitter/tweet/\_search?pretty=true](http://localhost:9200/twitter/tweet/_search?pretty=true)' -d '_  
> \*{ \*
> 
> - "query" : { \*
> - 
> 
> ```
> "fuzzy" : { "user": "kim" }*
> 
> ```
> 
> - } \*  
> _}'_  
> {  
> "took" : 2,  
> "timed\_out" : false,  
> "\_shards" : {  
> "total" : 5,  
> "successful" : 5,  
> "failed" : 0  
> },  
> "hits" : {  
> "total" : 0,  
> "max\_score" : null,  
> "hits" :   
> }  
> }  
> linlinfu-mac:~ linlinfu$

--  
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).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/38279284-ad29-43dd-b91f-218c016ea2fd%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/38279284-ad29-43dd-b91f-218c016ea2fd%40googlegroups.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:01am UTC](https://discuss.elastic.co/t/fuzzy-query/14831/3 "2017-07-06T02:01:48Z")

</div>


