# Special Characters in Query String

**URL:** <https://discuss.elastic.co/t/special-characters-in-query-string/224971>\
**Category:** Elasticsearch\
**Created:** [March 25, 2020, 10:30am UTC](https://discuss.elastic.co/t/special-characters-in-query-string/224971 "2020-03-25T10:30:11Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![mattiacareddu](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mattiacareddu/32/60917_2.png) [@mattiacareddu](https://discuss.elastic.co/u/mattiacareddu)\
**Post date:** [March 25, 2020, 10:30am UTC](https://discuss.elastic.co/t/special-characters-in-query-string/224971/1 "2020-03-25T10:30:11Z")

</div>

Hi, I'm having trouble trying to search special characters using query string. I need to search an email address in format "xxx@xxx.xxx". At index time I use a custom normalizer which provide lowercase and ascii folding. At search time I use a custom analyzer which provide a tokenizer for whitespace and a filter that apply lowercase and ascii folding. By the way I am not able to search for a simple email address.

This is my mapping

```
{
    "settings": {
        "number_of_shards": 5,
        "number_of_replicas": 1,
        "analysis": {
            "analyzer": {
                "folding": {
                    "tokenizer": "whitespace",
                    "filter": [
                        "lowercase",
                        "asciifolding"
                    ]
                }
            },
            "normalizer": {
                "lowerasciinormalizer": {
                    "type": "custom",
                    "filter": [
                        "lowercase",
                        "asciifolding"
                    ]
                }
            }
        }
    },
    "mappings": {
        "properties": {
            "id": {
                "type": "integer"
            },
           "email": {
                "type": "keyword",
                "normalizer": "lowerasciinormalizer"
            }
    }
}

```

And this is my search query

```
{
    "query": {
        "bool": {
            "must": [
                {
                    "query_string": {
                        "query": "pippo@pluto.it",
                        "fields": [
                            "email"
                        ],
                        "analyzer": "folding"
                    }
                }
            ]
        }
    }
}

```

Searching without special characters works fine. Infact if I do "query": "pippo\*" I get the correct results.  
I also tested the tokenizer doing  
GET /\_analyze

```
{
  "analyzer": "whitespace",
  "text": "pippo@pluto.com"
}

```

I get what I expect

```
{
  "tokens" : [
    {
      "token" : "pippo@pluto.com",
      "start_offset" : 0,
      "end_offset" : 15,
      "type" : "word",
      "position" : 0
    }
  ]
}

```

Any suggestions?  
Thanks.

---

<div class="post-metadata">

**Author:** ![mattiacareddu](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mattiacareddu/32/60917_2.png) [@mattiacareddu](https://discuss.elastic.co/u/mattiacareddu)\
**Post date:** [March 26, 2020, 11:47am UTC](https://discuss.elastic.co/t/special-characters-in-query-string/224971/2 "2020-03-26T11:47:16Z")

</div>

The problem was not in the analyzer. I have a problem in other fields mapping. This query works good.

---

<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:** [April 23, 2020, 11:47am UTC](https://discuss.elastic.co/t/special-characters-in-query-string/224971/3 "2020-04-23T11:47:16Z")

</div>

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