Property value on field n must be a number or a string but got o – How to solve this Elasticsearch exception

Opster Team

August-23, Version: 7.16-8.9

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 operation.

Briefly, this error occurs when the data type of the value assigned to a field in Elasticsearch is neither a number nor a string. Elasticsearch expects data types to be consistent with the mapping defined for the index. To resolve this, ensure that the data type of the value matches the field’s mapping. If the mapping is not defined, Elasticsearch will try to infer the data type based on the first document indexed. You can also explicitly define the mapping for the field to avoid such issues.

For a complete solution to your to your search operation, try for free AutoOps for Elasticsearch & OpenSearch . With AutoOps and Opster’s proactive support, you don’t have to worry about your search operation – we take charge of it. Get improved performance & stability with less hardware.

This guide will help you check for common problems that cause the log ” Property [value] on field [” + n + “] must be a number or a string; but got [” + o + “] ” to appear. To understand the issues related to this log, read the explanation below about the following Elasticsearch concepts: plugin.

Log Context

Log “Property [value] on field [” + n + “] must be a number or a string; but got [” + o + “]” class name is ConstantKeywordFieldMapper.java. We extracted the following from Elasticsearch source code for those seeking an in-depth context :

 // This is defined as updateable because it can be updated once; from [null] to any value;
 // by a dynamic mapping update. Once it has been set; however; the value cannot be changed.
 private final Parameter value = new Parameter<>("value"; true; () -> null; (n; c; o) -> {
 if (o instanceof Number == false && o instanceof CharSequence == false) {
 throw new MapperParsingException("Property [value] on field [" + n + "] must be a number or a string; but got [" + o + "]");
 }
 return o.toString();
 }; m -> toType(m).fieldType().value; XContentBuilder::field; Objects::toString);
 private final Parameter> meta = Parameter.metaParam();

 

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?