版本: 6.8-8.9
简要来说,当 Elasticsearch 接收到格式不正确的批量请求时,会出现此错误。在批量请求中,每个命令和数据应该以数组元素的形式在新行中指定。如果命令未遵循此结构,Elasticsearch 将抛出此错误。要解决此问题,请确保您的批量请求格式正确。每个命令及其数据应位于单独的行上。此外,请确保请求以换行符结尾。
日志上下文 #
日志 “commands should follow with an array element” 的类名是 AllocationCommands.java。我们从 Elasticsearch 源代码中提取了以下内容,供那些寻求深入上下文的人参考:
if (parser.currentName().equals("commands") == false) {
throw new ElasticsearchParseException("expected field name to be named [commands]; got [{}] instead"; parser.currentName());
}
token = parser.nextToken();
if (token != XContentParser.Token.START_ARRAY) {
throw new ElasticsearchParseException("commands should follow with an array element");
}
} else if (token == XContentParser.Token.START_ARRAY) {
// ok...
} else {
throw new ElasticsearchParseException("expected either field name [commands]; or start array; got [{}] instead"; token);





