# Return Levenshtein distance in fuzzy query

**URL:** <https://discuss.elastic.co/t/return-levenshtein-distance-in-fuzzy-query/20462>\
**Category:** Elasticsearch\
**Created:** [October 28, 2014, 1:27pm UTC](https://discuss.elastic.co/t/return-levenshtein-distance-in-fuzzy-query/20462 "2014-10-28T13:27:52Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Octavian](https://avatars.discourse-cdn.com/v4/letter/o/54ee81/32.png) [@Octavian](https://discuss.elastic.co/u/Octavian)\
**Post date:** [October 28, 2014, 1:27pm UTC](https://discuss.elastic.co/t/return-levenshtein-distance-in-fuzzy-query/20462/1 "2014-10-28T13:27:52Z")

</div>

Hy,

I want to return to closest phrase to a phrase stored in ElasticSearch, in  
terms of Levenshtein distance. Both phrases can contain several words (up  
to 100).

My query looks like:  
{  
"query": {  
"bool":  
{  
must: [ {"fuzzy\_like\_this": {  
"fields": [  
"stand\_for"  
],  
"like\_text": queryPhrase,  
"ignore\_tf": true,  
"fuzziness": 0.7,  
}}  
]  
}  
},  
"min\_score":2.0  
};

and the mapping looks like:  
{  
"stand\_for": {  
"type": "string"  
}

The problem is that the score returned is a relevance function of the terms  
that match the fuziness parameter and I need to return only the score based  
on Levenshtein distance. Is there any way to do this?

Thank you,

--  
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/bca80d78-8146-4f2a-b4e3-4cef2b731929%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/bca80d78-8146-4f2a-b4e3-4cef2b731929%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<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, 12:53am UTC](https://discuss.elastic.co/t/return-levenshtein-distance-in-fuzzy-query/20462/2 "2017-07-06T00:53:26Z")

</div>


