# Is fuzzy query in elasticsearch related to fuzzy logic?

**URL:** <https://discuss.elastic.co/t/is-fuzzy-query-in-elasticsearch-related-to-fuzzy-logic/39464>\
**Category:** Elasticsearch\
**Created:** [January 18, 2016, 3:17pm UTC](https://discuss.elastic.co/t/is-fuzzy-query-in-elasticsearch-related-to-fuzzy-logic/39464 "2016-01-18T15:17:45Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![full\_vlad](https://avatars.discourse-cdn.com/v4/letter/f/eb8c5e/32.png) [@full\_vlad](https://discuss.elastic.co/u/full_vlad)\
**Post date:** [January 18, 2016, 3:17pm UTC](https://discuss.elastic.co/t/is-fuzzy-query-in-elasticsearch-related-to-fuzzy-logic/39464/1 "2016-01-18T15:17:45Z")

</div>

As the title states, what exactly in Elasticsearch's fuzzy-query is related to fuzzy logic?

For example, given a string, a fuzzy query with fuzziness of 2 will return all indexed strings that have a Levenshtein distance of 2. How does the system decide what answers to return if there are multiple matches?

Is there a fuzzy system behind it? one that has triangular functions (for instance) and can be expressed in something like this:

```
1| A B
 | /\ /\ A = fuzzy set 1
 | / \/ \ B = fuzzy set 2
 | / /\ \
0|/ / \ \
 ------------
  a b c d

```

I would like a more theoretical answer that tackles what exactly in fuzzy queries is so fuzzy?

---

<div class="post-metadata">

**Author:** ![Mark\_Harwood](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mark_harwood/32/10538_2.png) [@Mark\_Harwood](https://discuss.elastic.co/u/Mark_Harwood)\
**Post date:** [January 18, 2016, 3:26pm UTC](https://discuss.elastic.co/t/is-fuzzy-query-in-elasticsearch-related-to-fuzzy-logic/39464/2 "2016-01-18T15:26:54Z")

</div>

Edit distance was one factor but TF-IDF was also part of the mix - IDF being handled badly until recently. See [https://issues.apache.org/jira/browse/LUCENE-329](https://issues.apache.org/jira/browse/LUCENE-329) for the recent IDF fixes.

---

<div class="post-metadata">

**Author:** ![full\_vlad](https://avatars.discourse-cdn.com/v4/letter/f/eb8c5e/32.png) [@full\_vlad](https://discuss.elastic.co/u/full_vlad)\
**Post date:** [January 18, 2016, 3:56pm UTC](https://discuss.elastic.co/t/is-fuzzy-query-in-elasticsearch-related-to-fuzzy-logic/39464/3 "2016-01-18T15:56:20Z")

</div>

Thanks very much for the quick answer, but I was looking to more of a begginers answer that also shows the mathematical model behind fuzzy queries in regard to fuzzy logic.

---

<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 5, 2017, 11:23pm UTC](https://discuss.elastic.co/t/is-fuzzy-query-in-elasticsearch-related-to-fuzzy-logic/39464/4 "2017-07-05T23:23:40Z")

</div>


