# Fulltext search with fuzziness on strings containing numbers

**URL:** <https://discuss.elastic.co/t/fulltext-search-with-fuzziness-on-strings-containing-numbers/116034>\
**Category:** Elasticsearch\
**Created:** [January 18, 2018, 11:47am UTC](https://discuss.elastic.co/t/fulltext-search-with-fuzziness-on-strings-containing-numbers/116034 "2018-01-18T11:47:51Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![nampord](https://avatars.discourse-cdn.com/v4/letter/n/e47c2d/32.png) [@nampord](https://discuss.elastic.co/u/nampord)\
**Post date:** [January 18, 2018, 11:47am UTC](https://discuss.elastic.co/t/fulltext-search-with-fuzziness-on-strings-containing-numbers/116034/1 "2018-01-18T11:47:51Z")

</div>

I have a use case where I need to match address strings.

Since the addresses come in many different shapes and forms I decided to put all fields in one string and do a full text search.

The main match will be done on the entity name, but also the address should match, alowing for some variations.

I observe some funny behaviour on the matching of the numbers embedded in the addresses :

Assume I have the following address

"10th Floor, Trustee House, 55 Samora Machel Avenue, Harare, ZW"

with a query

{  
"match": {  
"address\_list": {  
"query": "ADDRESS",  
"operator": "and",  
"fuzziness": "auto"  
}  
}  
}

I can find misspelled addresses like

ADDRESS = "10th Floor, Trust **e** House, 55 Samor **e** Machel Avenue, Harare, ZW"

and I can still find them if they moved a floor up

ADDRESS = "1 **1** th Floor, Truste House, 55 Samora Machel Avenue, Harare, ZW"

but if they move next door , I will not find them anymore :

ADDRESS = "10th Floor, Trustee House, 5 **6** Samore Machel Avenue, Harare, ZW"

if they move 100 houses up the street, I find them again :

ADDRESS = "10th Floor, Truste House, **1** 55 Samore Machel Avenue, Harare, ZW"

Is there as way to make fuzziness work also on the numbers in the string in a more predictable manner ?

---

<div class="post-metadata">

**Author:** ![mayya](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mayya/32/83147_2.png) [@mayya](https://discuss.elastic.co/u/mayya)\
**Post date:** [January 26, 2018, 11:40pm UTC](https://discuss.elastic.co/t/fulltext-search-with-fuzziness-on-strings-containing-numbers/116034/2 "2018-01-26T23:40:20Z")

</div>

Hi there,  
This is an expected behaviour. Fuzziness is calculated based on the Levenstein edit distance: [Common options | Elasticsearch Guide [8.11] | Elastic](https://www.elastic.co/guide/en/elasticsearch/reference/current/common-options.html#fuzziness)  
And your numbers are not represented as numbers, but as text tokens.

Your option `"auto"` means that an allowed edit distance will be based on the length of the term. For a short terms like your apartment `55`, the allowed distance could be even 0. Set `fuzziness` to 1 to allow 1 edit distance, and the apartment `56` will be found.

> "fuzziness": 1

Also, for a better control consider other fuzziness options, such as `prefix_length` and `transpositions`

---

<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:** [February 23, 2018, 11:40pm UTC](https://discuss.elastic.co/t/fulltext-search-with-fuzziness-on-strings-containing-numbers/116034/3 "2018-02-23T23:40:38Z")

</div>

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