Cannot define multifields on a field with a script – How to solve this Elasticsearch exception

Opster Team

August-23, Version: 7.13-8.9

Briefly, this error occurs when you try to define multifields on a scripted field in Elasticsearch. Scripted fields are computed at query time and do not support multifields, which are used to index a single field in different ways. To resolve this issue, you can either remove the multifield definition from the scripted field or create a separate non-scripted field for the multifield definition. Alternatively, you can modify your script to output data in a format that doesn’t require multifields.

This guide will help you check for common problems that cause the log ” Cannot define multifields on a field with a script ” to appear. To understand the issues related to this log, read the explanation below about the following Elasticsearch concepts: index.

Log Context

Log “Cannot define multifields on a field with a script” class name is We extracted the following from Elasticsearch source code for those seeking an in-depth context :

 scriptParam.addValidator(s -> {
 if (s != null && indexParam.get() == false && docValuesParam.get() == false) {
 throw new MapperParsingException("Cannot define script on field with index:false and doc_values:false");
 if (s != null && multiFieldsBuilder.hasMultiFields()) {
 throw new MapperParsingException("Cannot define multifields on a field with a script");
 if (s != null && copyTo.hasValues()) {
 throw new MapperParsingException("Cannot define copy_to parameter on a field with a script");


How helpful was this guide?

We are sorry that this post was not useful for you!

Let us improve this post!

Tell us how we can improve this post?