# Document(s) failed to index | mapper\_parsing\_exception

**URL:** <https://discuss.elastic.co/t/document-s-failed-to-index-mapper-parsing-exception/316690>\
**Category:** Elasticsearch\
**Created:** [October 15, 2022, 2:00pm UTC](https://discuss.elastic.co/t/document-s-failed-to-index-mapper-parsing-exception/316690 "2022-10-15T14:00:26Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![mohitthakkar\_ihm](https://avatars.discourse-cdn.com/v4/letter/m/f6c823/32.png) [@mohitthakkar\_ihm](https://discuss.elastic.co/u/mohitthakkar_ihm)\
**Post date:** [October 15, 2022, 2:00pm UTC](https://discuss.elastic.co/t/document-s-failed-to-index-mapper-parsing-exception/316690/1 "2022-10-15T14:00:26Z")

</div>

Hi,

I have an ES instance with the following mapping & config:

```auto
{
  "settings": {
    "number_of_shards": 5,
    "number_of_replicas": 1,
    "analysis": {
      "analyzer": {
        "custom_analyzer": {
          "tokenizer": "standard",
          "filter": [
            "custom_asciifolding",
            "lowercase"
          ]
        }
      },
      "filter": {
        "custom_asciifolding": {
          "type": "asciifolding",
          "preserve_original": true
        }
      },
      "normalizer": {
        "custom_normalizer": {
          "type": "custom",
          "char_filter": [],
          "filter": [
            "custom_asciifolding"
          ]
        }
      }
    }
  },
  "mappings": {
    "_doc": {
      "properties": {
        "artist_id": {
          "type": "integer"
        },
        "artist_genre": {
          "type": "keyword",
          "normalizer": "custom_normalizer"
        },
        "artist_name": {
          "type": "text",
          "analyzer": "custom_analyzer",
          "fields": {
            "raw": {
              "normalizer": "custom_normalizer",
              "type": "keyword"
            }
          }
        },
        "artist_type": {
          "type": "keyword",
          "normalizer": "custom_normalizer"
        },
        "associated_alias": {
          "type": "nested",
          "properties": {
            "alias_type": {
              "type": "keyword",
              "normalizer": "custom_normalizer"
            },
            "artist_id": {
              "type": "integer"
            },
            "artist_name": {
              "type": "text",
              "analyzer": "custom_analyzer"
            }
          }
        },
        "associated_artists": {
          "type": "nested",
          "properties": {
            "_id": {
              "type": "keyword"
            },
            "artist_id": {
              "type": "integer"
            },
            "artist_name": {
              "type": "text",
              "analyzer": "custom_analyzer"
            },
            "sequence_number": {
              "type": "integer"
            }
          }
        },
        "is_active": {
          "type": "boolean"
        },
        "record_provider_name": {
          "type": "keyword",
          "normalizer": "custom_normalizer"
        },
        "record_providers": {
          "type": "nested",
          "properties": {
            "name": {
              "type": "keyword",
              "normalizer": "custom_normalizer"
            },
            "count": {
              "type": "long"
            }
          }
        }
      }
    }
  }
}

```

While updating an existing document, I get the following error:

```auto
elasticsearch.exceptions.RequestError: RequestError(400, 'mapper_parsing_exception', \"failed to parse field [artist_name.raw] of type [keyword] in document with id 'uQRyF3sBPez8u38O8yMm'. Preview of field's value: 'Relajaci\u00f3n'\")"}

```

While creating a new document, I get a similar error:

```auto
      "error": {
        "type": "mapper_parsing_exception",
        "reason": "failed to parse field [artist_name.raw] of type [keyword] in document with id '8a9d479a-b665-4b49-97de-e4efcb7be446'. Preview of field's value: 'Andrea Miller, Alejandro Fernu00e1ndez Lecce'",
        "caused_by": {
          "type": "illegal_state_exception",
          "reason": "The normalization token stream is expected to produce exactly 1 token, but got 2+ for analyzer analyzer name[custom_normalizer], analyzer [org.elasticsearch.index.analysis.CustomAnalyzer@7c67f588], analysisMode [ALL] and input \"Andrea Miller, Alejandro Fernández Lecce\""
        }
      },

```

Please note that in both cases, there are some non-ASCII characters like `Fernández` and `Relajación`.

---

<div class="post-metadata">

**Author:** ![RabBit\_BR](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rabbit_br/32/82261_2.png) [@RabBit\_BR](https://discuss.elastic.co/u/RabBit_BR)\
**Post date:** [October 15, 2022, 9:14pm UTC](https://discuss.elastic.co/t/document-s-failed-to-index-mapper-parsing-exception/316690/2 "2022-10-15T21:14:10Z")

</div>

HI @mohitthakkar_ihm

Look the message:

> the normalization token stream is expected to produce exactly 1 token, but got 2+ for analyzer analyzer name[custom\_normalizer].

Your custom\_normalizer is generating two token due the config custom\_asciifolding:

```auto
  "custom_asciifolding": {
          "type": "asciifolding",
          "preserve_original": true
  }

```

Test your analyzer that use the custom\_asciifolding

```auto
GET idx_name/_analyze
{
  "analyzer": "custom_analyzer",
  "text": ["Fernández"]
}

{
  "tokens": [
    {
      "token": "Fernandez",
      "start_offset": 0,
      "end_offset": 9,
      "type": "<ALPHANUM>",
      "position": 0
    },
    {
      "token": "Fernández",
      "start_offset": 0,
      "end_offset": 9,
      "type": "<ALPHANUM>",
      "position": 0
    }
  ]
}

```

If you set preserve\_original to false the error will not happen. I don't know the reason to use preserve\_original = true, but it is the cause of your problem, maybe you need to think of another strategy to use normalize.

---

<div class="post-metadata">

**Author:** ![mohitthakkar\_ihm](https://avatars.discourse-cdn.com/v4/letter/m/f6c823/32.png) [@mohitthakkar\_ihm](https://discuss.elastic.co/u/mohitthakkar_ihm)\
**Post date:** [October 16, 2022, 8:52am UTC](https://discuss.elastic.co/t/document-s-failed-to-index-mapper-parsing-exception/316690/3 "2022-10-16T08:52:36Z")

</div>

Thanks @RabBit_BR

---

<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 13, 2022, 8:52am UTC](https://discuss.elastic.co/t/document-s-failed-to-index-mapper-parsing-exception/316690/4 "2022-11-13T08:52:58Z")

</div>

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