Field ” + currentFieldName + ” is a metadata field and cannot be added inside – How to solve this Elasticsearch error

Opster Team

July-20, Version: 1.7-8.0

Before you begin reading this guide, we recommend you try running the Elasticsearch Error Check-Up which analyzes 2 JSON files to detect many configuration errors.

Briefly, this error occurs when attempting to add a metadata field, such as _index or _type, to a nested object or array. Elasticsearch does not allow metadata fields to be added inside nested objects or arrays. To resolve the issue, you can try removing the metadata field from the nested object or array, or modifying the mapping to exclude the nested object or array.

To easily locate the root cause and resolve this issue try AutoOps for Elasticsearch & OpenSearch. It diagnoses problems by analyzing hundreds of metrics collected by a lightweight agent and offers guidance for resolving them.

Take a self-guided product tour to see for yourself (no registration required).

This guide will help you check for common problems that cause the log ” Field ” + currentFieldName + ” is a metadata field and cannot be added inside ” to appear. To understand the issues related to this log, read the explanation below about the following Elasticsearch concepts: metadata and index.

Log Context

Log “Field [” + currentFieldName + “] is a metadata field and cannot be added inside”classname  is DocumentParser.java We extracted the following from Elasticsearch source code for those seeking an in-depth context :

while (token != XContentParser.Token.END_OBJECT) {
 if (token == XContentParser.Token.FIELD_NAME) {
 currentFieldName = parser.currentName();
 paths = splitAndValidatePath(currentFieldName);
 if (context.mapperService().isMetadataField(context.path().pathAsText(currentFieldName))) {
 throw new MapperParsingException("Field [" + currentFieldName + "] is a metadata field and cannot be added inside"
 + " a document. Use the index API request parameters.");
 } else if (containsDisabledObjectMapper(mapper; paths)) {
 parser.nextToken();
 parser.skipChildren();
 }

 

Watch product tour

Try AutoOps to find & fix Elasticsearch problems

Analyze Your Cluster
Skip to content