# Searching text with reserved characters with fuzzy

**URL:** <https://discuss.elastic.co/t/searching-text-with-reserved-characters-with-fuzzy/240099>\
**Category:** Elasticsearch\
**Created:** [July 7, 2020, 6:39am UTC](https://discuss.elastic.co/t/searching-text-with-reserved-characters-with-fuzzy/240099 "2020-07-07T06:39:34Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![DaveG](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/daveg/32/46195_2.png) [@DaveG](https://discuss.elastic.co/u/DaveG)\
**Post date:** [July 7, 2020, 6:39am UTC](https://discuss.elastic.co/t/searching-text-with-reserved-characters-with-fuzzy/240099/1 "2020-07-07T06:39:34Z")

</div>

Hi All,

I have queries where I want to allow searching on part numbers/help ticket numbers and the like with reserved characters in them. For example:  
SR-1234  
SR/1234

The fields are analyzed with the standard analyzer and with an edge ngrams N=2 to 20.

When I query like this:

```auto
    {
        "query": {
            "bool": {
                "should": [
                    {
                        "simple_query_string": {
                            "query": "sr",
                            "fields": [
                                "PartNo", "PartNo.autocomplete"
                            ]
                        }
                    }
                ]
            }
        },
        "highlight": {
            "fields": {
                "PartNo": {}
            }
        }
    }

```

I get a result, the highlighter shows matches such as:  
sr -\> "_SR_/1234"  
sr-1234 -\> "_SR_/_1234_"

and this makes sense. The analyzer at index and search time has removed the "-", "/" etc and indexed sr and 1234 independently, and they are found independently.

Now, if I search with fuzzy by adding the ~:  
sr~ -\> "_SR_/1234". ok,  
but  
sr-1234~ -\> no results  
sr\-1234~ -\> no results

Can someone explain what fuzzy is doing here and if it is possible to formulate a query to achieve some level of fuzziness over the number (which is likely to be a ticket number/bug number and quite large, 8 digits or more)?  
I know the edge-ngrams will help with trailing uncertainty in the number (missing trailing characters), but if a user transposes 2 characters it will not help.

all thoughts appreciated,  
Dave.

---

<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:** [August 4, 2020, 6:39am UTC](https://discuss.elastic.co/t/searching-text-with-reserved-characters-with-fuzzy/240099/2 "2020-08-04T06:39:43Z")

</div>

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