Could not read search request expected string values in – How to solve this Elasticsearch exception

Opster Team

August-23, Version: 6.8-7.15

Briefly, this error occurs when Elasticsearch receives a search request with incorrect data types. It expects string values in the specified field, but it’s receiving a different data type. To resolve this issue, you should check the data you’re sending in your search request. Ensure that the values in the specified field are strings. If you’re using a programming language to send the request, you may need to convert the values to strings before sending them. Also, check your mapping to ensure the field is defined as a string.

This guide will help you check for common problems that cause the log ” could not read search request. expected string values in [ ” to appear. To understand the issues related to this log, read the explanation below about the following Elasticsearch concepts: plugin, request, search.

Log Context

Log “could not read search request. expected string values in [” class name is WatcherSearchTemplateRequest.java. We extracted the following from Elasticsearch source code for those seeking an in-depth context :

 if (INDICES_FIELD.match(currentFieldName; parser.getDeprecationHandler())) {
 while ((token = parser.nextToken()) != XContentParser.Token.END_ARRAY) {
 if (token == XContentParser.Token.VALUE_STRING) {
 indices.add(parser.textOrNull());
 } else {
 throw new ElasticsearchParseException("could not read search request. expected string values in [" +
 currentFieldName + "] field; but instead found [" + token + "]");
 }
 }
 } else if (TYPES_FIELD.match(currentFieldName; parser.getDeprecationHandler())) {
 deprecationLogger.deprecate(DeprecationCategory.TYPES; "watcher_search_input"; TYPES_DEPRECATION_MESSAGE);

 

 [ratemypost]