# Levenshtein ratio query

**URL:** <https://discuss.elastic.co/t/levenshtein-ratio-query/212783>\
**Category:** Elasticsearch\
**Created:** [December 22, 2019, 4:23pm UTC](https://discuss.elastic.co/t/levenshtein-ratio-query/212783 "2019-12-22T16:23:59Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Or\_Chen](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/or_chen/32/59849_2.png) [@Or\_Chen](https://discuss.elastic.co/u/Or_Chen)\
**Post date:** [December 22, 2019, 4:24pm UTC](https://discuss.elastic.co/t/levenshtein-ratio-query/212783/1 "2019-12-22T16:24:00Z")

</div>

Hello, I am trying to get all results which are above a certain ratio of similarity using levenshtein distance. say, if my query has 21 charaters, I want to find all documents who have 3 levenshtein distance or below.  
I am using fuzzy query to this, however I have an issue with the limit of 2 on the fuzziness field.

For example, my documents are like this:  
// {"string\_field": "langwerdwiththreechenges"}  
and I wanna find it when searching for longwordwiththreechanges.  
Any idea on how it could be done?

I've tried indexing with n-gram tokenizer set to min: 1 max: 1, and searching it with either match\_phrase with slop or match with minimum should match 90%. the first didn't return all results, the second didn't take into account the order of the tokens.  
Iv'e also tried tri-grams but it didn't produce exactly the required result

---

<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:** [January 19, 2020, 4:24pm UTC](https://discuss.elastic.co/t/levenshtein-ratio-query/212783/2 "2020-01-19T16:24:03Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
