# Danish special chars (Æ, Ø, Å) are seen as æ==a/ae, ø == o, å == a

**URL:** https://discuss.elastic.co/t/danish-special-chars-ae-o-a-are-seen-as-ae-a-ae-o-o-a-a/105219
**Category:** Elasticsearch
**Created:** [October 25, 2017, 10:19am UTC](https://discuss.elastic.co/t/danish-special-chars-ae-o-a-are-seen-as-ae-a-ae-o-o-a-a/105219 "2017-10-25T10:19:04Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![smhoeks](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/smhoeks/32/23395_2.png) [@smhoeks](https://discuss.elastic.co/u/smhoeks)
#### Post date: [October 25, 2017, 10:19am UTC](https://discuss.elastic.co/t/danish-special-chars-ae-o-a-are-seen-as-ae-a-ae-o-o-a-a/105219/1 "2017-10-25T10:19:04Z")

</div>

Hi All 🙂

I'm facing a problem with my elastic search for Magento 2 (Wyomind)

In general, it seems the danish special characters Æ, Ø and Å are translated to:  
Æ: A /Ae  
Ø: O  
Å: A

This causes the search not to show the exact products.

E.g.

1. If i Search for "Nål" It will find "anal" (analytic) because of 'nal' is seen as the same as "nål" becuase of Å == A.
2. If i search for "åle" it will return "male" (because of ale)

In general - elastic should only find exact matches - and not read the special chars as regular chars.

Hope you guys can help me out.

Here are the setup of my elastic search.

{  
"number\_of\_shards": 1,  
"number\_of\_replicas": 0,  
"analysis": {  
"analyzer": {  
"std": {  
"tokenizer": "standard",  
"char\_filter": "html\_strip",  
"filter": ["standard", "elision", "asciifolding", "lowercase", "length"]  
},  
"keyword": {  
"tokenizer": "keyword",  
"filter": ["asciifolding", "lowercase"]  
},  
"keyword\_prefix": {  
"tokenizer": "keyword",  
"filter": ["asciifolding", "lowercase", "edge\_ngram\_front"]  
},  
"text\_prefix": {  
"tokenizer": "standard",  
"char\_filter": "html\_strip",  
"filter": ["standard", "elision", "asciifolding", "lowercase", "edge\_ngram\_front"]  
},  
"text\_suffix": {  
"tokenizer": "standard",  
"char\_filter": "html\_strip",  
"filter": ["standard", "elision", "asciifolding", "lowercase", "edge\_ngram\_back"]  
}  
},  
"filter": {  
"edge\_ngram\_front": {  
"type": "edgeNGram",  
"min\_gram": 2,  
"max\_gram": 10,  
"side": "front"  
},  
"edge\_ngram\_back": {  
"type": "edgeNGram",  
"min\_gram": 2,  
"max\_gram": 10,  
"side": "back"  
},  
"length": {  
"type": "length",  
"min": 1  
}  
}  
}  
}

---

<div class="post-metadata">

### Author: ![danielmitterdorfer](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/danielmitterdorfer/32/110510_2.png) [@danielmitterdorfer](https://discuss.elastic.co/u/danielmitterdorfer)
#### Post date: [October 25, 2017, 12:40pm UTC](https://discuss.elastic.co/t/danish-special-chars-ae-o-a-are-seen-as-ae-a-ae-o-o-a-a/105219/2 "2017-10-25T12:40:05Z")

</div>

Hi @smhoeks,

any reason you are not using the [built-in danish analyzer](https://www.elastic.co/guide/en/elasticsearch/reference/current/analysis-lang-analyzer.html)? This would probably be the simplest option.

You can use the [analyze API](https://www.elastic.co/guide/en/elasticsearch/reference/current/_testing_analyzers.html) to test your analyzer. E.g.:

```auto
PUT /sample-index
{
   "settings": {
      "number_of_shards": 1,
      "number_of_replicas": 0,
      "analysis": {
         "analyzer": {
            "std": {
               "tokenizer": "standard",
               "char_filter": "html_strip",
               "filter": [
                  "standard",
                  "elision",
                  "asciifolding",
                  "lowercase",
                  "length"
               ]
            },
            "keyword": {
               "tokenizer": "keyword",
               "filter": [
                  "asciifolding",
                  "lowercase"
               ]
            },
            "keyword_prefix": {
               "tokenizer": "keyword",
               "filter": [
                  "asciifolding",
                  "lowercase",
                  "edge_ngram_front"
               ]
            },
            "text_prefix": {
               "tokenizer": "standard",
               "char_filter": "html_strip",
               "filter": [
                  "standard",
                  "elision",
                  "asciifolding",
                  "lowercase",
                  "edge_ngram_front"
               ]
            },
            "text_suffix": {
               "tokenizer": "standard",
               "char_filter": "html_strip",
               "filter": [
                  "standard",
                  "elision",
                  "asciifolding",
                  "lowercase",
                  "edge_ngram_back"
               ]
            }
         },
         "filter": {
            "edge_ngram_front": {
               "type": "edgeNGram",
               "min_gram": 2,
               "max_gram": 10,
               "side": "front"
            },
            "edge_ngram_back": {
               "type": "edgeNGram",
               "min_gram": 2,
               "max_gram": 10,
               "side": "back"
            },
            "length": {
               "type": "length",
               "min": 1
            }
         }
      }
   }
}

```

```auto
POST /sample-index/_analyze
{
  "analyzer": "std",
  "text": "Nål"
}

```

produces:

```auto
{
   "tokens": [
      {
         "token": "nal",
         "start_offset": 0,
         "end_offset": 3,
         "type": "<ALPHANUM>",
         "position": 0
      }
   ]
}

```

but

```auto
POST /sample-index/_analyze
{
  "analyzer": "danish",
  "text": "Nål"
}

```

produces

```auto
{
   "tokens": [
      {
         "token": "nål",
         "start_offset": 0,
         "end_offset": 3,
         "type": "<ALPHANUM>",
         "position": 0
      }
   ]
}

```

Daniel

---

<div class="post-metadata">

### Author: ![smhoeks](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/smhoeks/32/23395_2.png) [@smhoeks](https://discuss.elastic.co/u/smhoeks)
#### Post date: [October 25, 2017, 1:27pm UTC](https://discuss.elastic.co/t/danish-special-chars-ae-o-a-are-seen-as-ae-a-ae-o-o-a-a/105219/3 "2017-10-25T13:27:59Z")

</div>

Hi Daniel

Thanks your answer.

I've tried your solution, but maybe im missing something here?  
Do i need to change it from "std" to "danish" in? (Im new to elastic)  
"analysis":{  
"analyzer":{  
" **std**":{

{  
"number\_of\_shards":1,  
"number\_of\_replicas":0,  
"analysis":{  
"analyzer":{  
"std":{  
"tokenizer":"standard",  
"char\_filter":"html\_strip",  
"filter":[  
"standard",  
"danish\_stemmer",  
"elision",  
"asciifolding",  
"lowercase",  
"length"  
]  
},  
"keyword":{  
"tokenizer":"keyword",  
"filter":[  
"asciifolding",  
"lowercase"  
]  
},  
"danish":{  
"tokenizer":"standard",  
"filter":["danish\_stemmer"]  
},  
"keyword\_prefix":{  
"tokenizer":"keyword",  
"filter":[  
"asciifolding",  
"lowercase",  
"edge\_ngram\_front"  
]  
},  
"text\_prefix":{  
"tokenizer":"standard",  
"char\_filter":"html\_strip",  
"filter":[  
"standard",  
"elision",  
"asciifolding",  
"lowercase",  
"edge\_ngram\_front"  
]  
},  
"text\_suffix":{  
"tokenizer":"standard",  
"char\_filter":"html\_strip",  
"filter":[  
"standard",  
"elision",  
"asciifolding",  
"lowercase",  
"edge\_ngram\_back"  
]  
}  
},  
"filter":{  
"edge\_ngram\_front":{  
"type":"edgeNGram",  
"min\_gram":2,  
"max\_gram":10,  
"side":"front"  
},  
"edge\_ngram\_back":{  
"type":"edgeNGram",  
"min\_gram":2,  
"max\_gram":10,  
"side":"back"  
},  
"length":{  
"type":"length",  
"min":1  
},  
"danish\_stemmer":{  
"type":"stemmer",  
"language":"danish"  
}  
}  
}  
}

We've added a danish libstemmer to server as well, but maybe this is not needed?

---

<div class="post-metadata">

### Author: ![danielmitterdorfer](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/danielmitterdorfer/32/110510_2.png) [@danielmitterdorfer](https://discuss.elastic.co/u/danielmitterdorfer)
#### Post date: [October 25, 2017, 1:58pm UTC](https://discuss.elastic.co/t/danish-special-chars-ae-o-a-are-seen-as-ae-a-ae-o-o-a-a/105219/4 "2017-10-25T13:58:21Z")

</div>

Hi @smhoeks,

You can [set the default analyzer for an index](https://www.elastic.co/guide/en/elasticsearch/reference/current/analysis.html#_specifying_an_index_time_analyzer) in the index settings:

```auto
PUT my_index
{
  "settings": {
    "analysis": {
      "analyzer": {
        "default": {
          "type": "danish"
        }
      }
    }
  }
}

```

Note that it has to have the name `default` to be recognized as the default analyzer for that index. You can set different analyzers also per field (see the docs link above). You had quite some customization in your original analyzer. If you need all that, you probably want to start [customizing the danish analyzer](https://www.elastic.co/guide/en/elasticsearch/reference/current/analysis-lang-analyzer.html#danish-analyzer).

> [@smhoeks](#):
>
> We've added a danish libstemmer to server as well, but maybe this is not needed?

I don't know what that is but there are not third-party libraries needed. The danish analyzer is already built into Elasticsearch.

Daniel

---

<div class="post-metadata">

### Author: ![smhoeks](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/smhoeks/32/23395_2.png) [@smhoeks](https://discuss.elastic.co/u/smhoeks)
#### Post date: [October 27, 2017, 11:31am UTC](https://discuss.elastic.co/t/danish-special-chars-ae-o-a-are-seen-as-ae-a-ae-o-o-a-a/105219/5 "2017-10-27T11:31:03Z")

</div>

@danielmitterdorfer

Thanks, i got it to work now.  
I changed the analyzer from what it was to danish.

Still faced problems after, but found out that 'asciifolding' was still converting my special chars - after i removed that filter, it all worked.

THanks!

---

<div class="post-metadata">

### Author: ![danielmitterdorfer](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/danielmitterdorfer/32/110510_2.png) [@danielmitterdorfer](https://discuss.elastic.co/u/danielmitterdorfer)
#### Post date: [October 27, 2017, 11:47am UTC](https://discuss.elastic.co/t/danish-special-chars-ae-o-a-are-seen-as-ae-a-ae-o-o-a-a/105219/6 "2017-10-27T11:47:15Z")

</div>

Hi @smhoeks,

glad to hear that all is well now. 🙂

Daniel

---

<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: [November 24, 2017, 11:48am UTC](https://discuss.elastic.co/t/danish-special-chars-ae-o-a-are-seen-as-ae-a-ae-o-o-a-a/105219/7 "2017-11-24T11:48:05Z")

</div>

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