Normalizer normalizerName not found for field name – How to solve this Elasticsearch exception

Opster Team

August-23, Version: 6.8-8.9

Briefly, this error occurs when Elasticsearch tries to apply a normalizer to a field, but the normalizer specified in the mapping doesn’t exist. Normalizers are used to preprocess keyword fields before indexing. To resolve this issue, you can either create a normalizer with the specified name in the index settings or change the field mapping to use an existing normalizer. Also, ensure that the normalizer is correctly defined and that there are no typos or syntax errors in its name.

Before you dig into reading this guide, have you tried asking OpsGPT what this log means? You’ll receive a customized analysis of your log.

Try OpsGPT now for step-by-step guidance and tailored insights into your Elasticsearch/OpenSearch operation.

To fully understand why you need to define a normalizer before using it, you should run the AutoOps for Elasticsearch. It will help you resolve this issue and prevent it in the future.

This guide will help you check for common problems that cause the log “normalizer ” + normalizerName + ” not found for field ” + name + “” to appear. It’s important to understand the issues related to the log, so to get started, read the general overview on common issues and tips related to the Elasticsearch concept: index.

Background

Elasticsearch has only a lowercase built-in normalizer so far, so using any other normalizer requires building a custom one. A normalizer needs to be defined under the analysis settings section when creating an index. The normalizer is applied before indexing the field value. 

You have to use the same normalizer name (that you have defined in the settings) when adding it for a particular field in the mapping section. The above error arises when the normalizer used in the mapping for a particular field is not defined in the analysis settings section.

How to reproduce this exception

Create index:

PUT /my-index
{
 "settings": {
   "analysis": {
     "normalizer": {
       "my_normalizer": {
         "type": "custom",
         "char_filter": [],
         "filter": ["lowercase", "asciifolding"]
       }
     }
   }
 },
 "mappings": {
   "properties": {
     "opster": {
       "type": "keyword",
       "normalizer": "lower_normalizer"
     }
   }
 }
}

The response generated will be:

{
 "error": {
   "root_cause": [
     {
       "type": "mapper_parsing_exception",
       "reason": "normalizer [lower_normalizer] not found for field [opster]"
     }
   ],
   "type": "mapper_parsing_exception",
   "reason": "Failed to parse mapping [_doc]: normalizer [lower_normalizer] not found for field [opster]",
   "caused_by": {
     "type": "mapper_parsing_exception",
     "reason": "normalizer [lower_normalizer] not found for field [opster]"
   }
 },
 "status": 400
}

How to fix this exception

The exception clearly describes that the normalizer specified for the field opster, does not exist. You need to define the normalizer, in the settings of the index before using it on a field.

To define the normalizer in your settings, recreate your index like this:

PUT /my-index
{
 "settings": {
   "analysis": {
     "normalizer": {
       "my_normalizer": {
         "type": "custom",
         "char_filter": [],
         "filter": ["lowercase", "asciifolding"]
       }
     }
   }
 },
 "mappings": {
   "properties": {
     "foo": {
       "type": "keyword",
       "normalizer": "my_normalizer"
     }
   }
 }
}

The response generated will be:

{
 "acknowledged": true,
 "shards_acknowledged": true,
 "index": "my-index"
}

Log Context

Log “normalizer [” + normalizerName + “] not found for field [” + name + “]” class name is KeywordFieldMapper.java. We extracted the following from Elasticsearch source code for those seeking an in-depth context :

 logger.warn(
 () -> format("Could not find normalizer [%s] of legacy index; falling back to default"; normalizerName)
 );
 normalizer = Lucene.KEYWORD_ANALYZER;
 } else {
 throw new MapperParsingException("normalizer [" + normalizerName + "] not found for field [" + name + "]");
 }
 }
 searchAnalyzer = quoteAnalyzer = normalizer;
 if (splitQueriesOnWhitespace.getValue()) {
 searchAnalyzer = indexAnalyzers.getWhitespaceNormalizer(normalizerName);

 

 [ratemypost]