# Make search with special characters insensitive

**URL:** <https://discuss.elastic.co/t/make-search-with-special-characters-insensitive/188330>\
**Category:** Elasticsearch\
**Created:** [July 1, 2019, 1:39pm UTC](https://discuss.elastic.co/t/make-search-with-special-characters-insensitive/188330 "2019-07-01T13:39:56Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![tomsk](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/tomsk/32/22061_2.png) [@tomsk](https://discuss.elastic.co/u/tomsk)\
**Post date:** [July 1, 2019, 1:39pm UTC](https://discuss.elastic.co/t/make-search-with-special-characters-insensitive/188330/1 "2019-07-01T13:39:56Z")

</div>

Hello, firstly sorry if this is wrong section and I am beginner, but I need help with search query for Elasticsearch.

I use Elasticsearch as search engine for my website. People can search for products and as you can see below I show products based on fields like **status** , **datetime\_publish\_start** , **cat\_path** and **metahash**. I know that this script is very **non effective** , but I don't know how to make it better, I have no skills yet.

**Search logic looks like this:**  
User write for example **kufor modrý** into search, then I split this sentence into keywords by whitespaces, so I will get keywords like **kufor** and **modrý** , and then I search these keywords against field **metahash.meta.alternative\_name** (result must contain all keywords) and I will check field **product\_number** too in case user wrote product number.

**But problem is that** , if user write for example **kufor modry** (without special character "ý"), then I split it into **kufor** and **modry** and I find nothing, because data in **metahash.meta.alternative\_name** are saved with special characters. So I really don't know how to make search with special characters insensitive.

**This is query for Elasticsearch in JSON format what I use:**

```
{  
    "query":{  
        "constant_score":{  
            "filter":{  
                "bool":{  
                    "must":[  
                        {  
                            "term":{  
                                "status":"y"
                            }
                        },
                        {  
                            "range":{  
                                "datetime_publish_start":{  
                                    "lte":"now/h"
                                }
                            }
                        },
                        {  
                            "term":{  
                                "cat_path":30
                            }
                        }
                    ],
                    "must_not":[  
                        {  
                            "term":{  
                                "metahash.meta.sold_out":"y"
                            }
                        }
                    ],
                    "should":[  
                        {  
                            "bool":{  
                                "must":[  
                                    {  
                                        "wildcard":{  
                                            "metahash.meta.alternative_name":"*kufor*"
                                        }
                                    },
                                    {  
                                        "wildcard":{  
                                            "metahash.meta.alternative_name":"*modrý*"
                                        }
                                    }
                                ]
                            }
                        },
                        {  
                            "term":{  
                                "product_number":"kufor modrý"
                            }
                        }
                    ]
                }
            }
        }
    },
    "sort":[  
        {  
            "ID_entity":{  
                "order":"desc"
            }
        }
    ]
}

```

Thank you very much for any help.

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [July 1, 2019, 3:29pm UTC](https://discuss.elastic.co/t/make-search-with-special-characters-insensitive/188330/2 "2019-07-01T15:29:17Z")

</div>

Could you provide a full recreation script as described in [About the Elasticsearch category](https://discuss.elastic.co/t/about-the-elasticsearch-category/21). It will help to better understand what you are doing. Please, try to keep the example as simple as possible.

A full reproduction script will help readers to understand, reproduce and if needed fix your problem. It will also most likely help to get a faster answer.

---

<div class="post-metadata">

**Author:** ![telendt](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/telendt/32/3416_2.png) [@telendt](https://discuss.elastic.co/u/telendt)\
**Post date:** [July 1, 2019, 3:36pm UTC](https://discuss.elastic.co/t/make-search-with-special-characters-insensitive/188330/3 "2019-07-01T15:36:33Z")

</div>

You should fold `metahash.meta.alternative_name` to ASCII characters:

[https://www.elastic.co/guide/en/elasticsearch/reference/7.2/analysis-asciifolding-tokenfilter.html](https://www.elastic.co/guide/en/elasticsearch/reference/7.2/analysis-asciifolding-tokenfilter.html)  
[https://www.elastic.co/guide/en/elasticsearch/plugins/current/analysis-icu-folding.html](https://www.elastic.co/guide/en/elasticsearch/plugins/current/analysis-icu-folding.html)

---

<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 29, 2019, 3:36pm UTC](https://discuss.elastic.co/t/make-search-with-special-characters-insensitive/188330/4 "2019-07-29T15:36:33Z")

</div>

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