📣 极限科技诚招搜索运维工程师(Elasticsearch/Easysearch)- 全职/北京 👉 : 立即申请加入

版本: 6.8-7.15

简而言之,当 Elasticsearch 无法解析日期/时间字段时会抛出此错误,因为字段格式不符合预期。Elasticsearch 期望日期字段是数字或特定格式的字符串。要解决此问题,请确保日期/时间字段采用正确的格式。如果是字符串,应遵循 ISO 8601 格式。如果是数字,应为自 Unix 纪元以来的毫秒数。此外,请检查您的映射以确保该字段被正确定义为日期类型。

日志上下文 #


日志“could not parse date/time. expected date field [{}] to be either a number or a”的类名是 WatcherDateTimeUtils.java。 我们从 Elasticsearch 源代码中提取了以下内容,供那些寻求深入了解的人参考:

    }
    if (token == XContentParser.Token.VALUE_STRING) {
        try {
            return parseDateMath(parser.text(), timeZone, clock);
        } catch (ElasticsearchParseException epe) {
            throw new ElasticsearchParseException("could not parse date/time. expected date field [{}] to be either a number or a " +
                "DateMath string but found [{}] instead", epe, fieldName, parser.text());
        }
    }
    if (token == XContentParser.Token.VALUE_NULL) {
        return null;