版本: 6.8-7.15
简而言之,当 Elasticsearch 尝试解析一个预期应该有值但实际为 null 的日期/时间字段时,就会出现此错误。这可能是由于数据输入不正确或映射配置错误导致的。要解决此问题,您可以确保在索引文档时日期字段永远不为 null,或者调整映射以允许日期字段接受 null 值。或者,您可以在解析过程中使用脚本来处理 null 值。
日志上下文 #
日志“could not parse date/time expected date field [{}] to not be null but was null”的类名是 WatcherDateTimeUtils.java。 我们从 Elasticsearch 源代码中提取了以下内容,供那些寻求深入背景信息的人参考:
return dateTimeFormatter.format(date);
} public static ZonedDateTime parseDateMath(String fieldName, XContentParser parser, ZoneId timeZone, Clock clock) throws IOException {
if (parser.currentToken() == XContentParser.Token.VALUE_NULL) {
throw new ElasticsearchParseException("could not parse date/time expected date field [{}] to not be null but was null",
fieldName);
}
return parseDateMathOrNull(fieldName, parser, timeZone, clock);
}





