# Unable to setup a normalizer on a keyword using dynamic mapping

**URL:** <https://discuss.elastic.co/t/unable-to-setup-a-normalizer-on-a-keyword-using-dynamic-mapping/144040>\
**Category:** Elasticsearch\
**Created:** [August 12, 2018, 4:50pm UTC](https://discuss.elastic.co/t/unable-to-setup-a-normalizer-on-a-keyword-using-dynamic-mapping/144040 "2018-08-12T16:50:43Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![vboulaye](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/vboulaye/32/34409_2.png) [@vboulaye](https://discuss.elastic.co/u/vboulaye)\
**Post date:** [August 12, 2018, 4:50pm UTC](https://discuss.elastic.co/t/unable-to-setup-a-normalizer-on-a-keyword-using-dynamic-mapping/144040/1 "2018-08-12T16:50:44Z")

</div>

Hi,

I would like to add a custom normalizer on my keyword fields.  
I followed up the indications in [Adding a normalizer for case-insensitive search on keyword field to an active index](https://discuss.elastic.co/t/adding-a-normalizer-for-case-insensitive-search-on-keyword-field-to-an-active-index/106725/3)

It works fine when I apply it to a field in the mapping definition. But as I would like this to be the defaults for strings in my index, I did the setup using a dynamic mapping.  
The dynamic mapping is accepted, but when a new field is effectively added, the normalizer is not applied.

I tested it on ES 5.6.4 and 6.3.1 running on the jvm v1.8.0\_60

here is a small test that reproduce the issue:

```
# creates a dynamic template with the normalizer + one custom field with the normalizer + a dynamic rule for new fields
PUT _template/test-analyser
{ "order": 0,
  "template": "analyser-*",
  "settings": {
    "index": {
      "analysis": {
        "normalizer": {
          "lowerascii": {
            "type": "custom",
            "filter": [
              "lowercase",
              "asciifolding"
            ]
          }
        }
      }
    }
  },
  "mappings": {
    "log": {
      "dynamic_templates": [
        {
          "standard_string_fields": {
            "match_mapping_type": "string",
            "mapping": {
              "type": "keyword",
              "normaliser": "lowerascii"
            }
          }
        }
      ],
      "properties": {
        "field_defined_in_mapping": {
          "type": "keyword",
          "normalizer": "lowerascii"
        }
      }
    }
  }
  
}

# add a doc with the existing field
PUT analyser-2018.08.22/log/1
{
  "field_defined_in_mapping":"TEST"
}

# add a doc with a new field
PUT analyser-2018.08.22/log/2
{
  "new_field": "TEST"
}

# case insensitive search on the first field
GET analyser-2018.08.22/_search?q=field_defined_in_mapping:test
# returns doc 1 (which is expected)

# case insensitive search on the new field
GET analyser-2018.08.22/_search?q=new_field:test
# returns nothing

GET analyser-2018.08.22

# in the mapping definition the normalizer is not applied to the new field
# "log": {
# "properties": {
# "field_defined_in_mapping": {
# "type": "keyword",
# "normalizer": "lowerascii"
# },
# "new_field": {
# "type": "keyword"
# }
# }

```

Is it possible to define a normalizer inside a dynamic mapping?

---

<div class="post-metadata">

**Author:** ![thiago](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/thiago/32/32096_2.png) [@thiago](https://discuss.elastic.co/u/thiago)\
**Post date:** [August 12, 2018, 9:56pm UTC](https://discuss.elastic.co/t/unable-to-setup-a-normalizer-on-a-keyword-using-dynamic-mapping/144040/2 "2018-08-12T21:56:02Z")

</div>

> [@vboulaye](#):
>
> "mapping": { "type": "keyword", "normaliser": "lowerascii" }

Your dynamic template is defining `normaliser`, with an `s`. Try with `normalizer`.

I have not tested this yet, but I would expect an exception instead of failing silently.

---

<div class="post-metadata">

**Author:** ![vboulaye](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/vboulaye/32/34409_2.png) [@vboulaye](https://discuss.elastic.co/u/vboulaye)\
**Post date:** [August 13, 2018, 5:10am UTC](https://discuss.elastic.co/t/unable-to-setup-a-normalizer-on-a-keyword-using-dynamic-mapping/144040/3 "2018-08-13T05:10:56Z")

</div>

Thanks a lot, that was it, now the fields are indexed with the normaliZer applied!

---

<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:** [September 10, 2018, 5:11am UTC](https://discuss.elastic.co/t/unable-to-setup-a-normalizer-on-a-keyword-using-dynamic-mapping/144040/4 "2018-09-10T05:11:12Z")

</div>

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