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

Opster Team

August-23, Version: 6.8-7.9

Briefly, this error occurs when you try to add a metadata field inside a document in Elasticsearch. Metadata fields are system fields that hold information about the document itself, like “_index”, “_type”, “_id”, etc. They cannot be added or modified directly. To resolve this issue, you should avoid using metadata field names for your custom fields. If you need to store similar information, use a different field name that doesn’t conflict with the reserved metadata field names.

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: index, metadata.

Log Context

Log “Field [” + currentFieldName + “] is a metadata field and cannot be added inside” class name 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();
 }

 

 [ratemypost]

Opster
Privacy Overview

This website uses cookies so that we can provide you with the best user experience possible. Cookie information is stored in your browser and performs functions such as recognising you when you return to our website and helping our team to understand which sections of the website you find most interesting and useful.