版本: 6.8-8.9
简要来说,当 Elasticsearch 期望请求体中存在名为 “commands” 的字段,但接收到空对象或其他字段名时,会出现此错误。这可能是由于请求中的拼写错误或格式不正确导致的。要解决此问题,你应该检查请求体,确保字段名正确拼写为 “commands”。此外,确保该字段不为空且包含有效数据。如果错误仍然存在,请检查 Elasticsearch 版本,因为不同版本中字段名可能已更改。
日志上下文 #
日志 “expected field name to be named [commands]; got [{}] instead” 的类名是 AllocationCommands.java。我们从 Elasticsearch 源代码中提取了以下内容,为那些寻求深入上下文的人提供参考:
if (token == null) {
throw new ElasticsearchParseException("No commands");
}
if (token == XContentParser.Token.FIELD_NAME) {
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");
}





