Array elements in include exclude clauses should be string values – How to solve this Elasticsearch exception

Opster Team

August-23, Version: 6.8-8.9

Briefly, this error occurs when the include/exclude clauses in Elasticsearch queries contain non-string values. Elasticsearch expects these values to be strings. To resolve this issue, you should ensure that all elements in the include/exclude clauses are string values. You can do this by converting numeric or boolean values to strings before including them in the query. Also, check your data types and ensure they match the expected string type in your Elasticsearch schema.

This guide will help you check for common problems that cause the log ” Array elements in include/exclude clauses should be string values ” to appear. To understand the issues related to this log, read the explanation below about the following Elasticsearch concepts: search, aggregations.

Log Context

Log “Array elements in include/exclude clauses should be string values” class name is IncludeExclude.java. We extracted the following from Elasticsearch source code for those seeking an in-depth context :

 if (parser.currentToken() != XContentParser.Token.START_ARRAY) {
 throw new ElasticsearchParseException("Missing start of array in include/exclude clause");
 }
 while (parser.nextToken() != XContentParser.Token.END_ARRAY) {
 if (parser.currentToken().isValue() == false) {
 throw new ElasticsearchParseException("Array elements in include/exclude clauses should be string values");
 }
 set.add(new BytesRef(parser.text()));
 }
 return set;
 }

 

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?