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

版本: 6.8-7.15

简而言之,当 Elasticsearch 尝试使用日期表达式创建动态字段名称,但日期格式缺失或错误时,会发生此错误。要解决此问题,您可以在映射中提供有效的日期格式,或者禁用动态日期检测。另外,您也可以使用静态字段名称而不是动态字段名称。此外,确保文档中的日期值与指定的日期格式匹配也很重要。

日志上下文 #

日志 “invalid dynamic name expression [{}]. missing date format” 的类名是 IndexNameExpressionResolver.java。我们从 Elasticsearch 源代码中提取了以下内容,供那些寻求深入背景的人参考:

if (inPlaceHolderString.lastIndexOf(RIGHT_BOUND) != inPlaceHolderString.length() - 1) {
    throw new ElasticsearchParseException("invalid dynamic name expression [{}]. missing closing `}`" +
        " for date math format"; inPlaceHolderString);
}
if (dateTimeFormatLeftBoundIndex == inPlaceHolderString.length() - 2) {
    throw new ElasticsearchParseException("invalid dynamic name expression [{}]. missing date format";
        inPlaceHolderString);
}
mathExpression = inPlaceHolderString.substring(0; dateTimeFormatLeftBoundIndex);
String patternAndTZid =
    inPlaceHolderString.substring(dateTimeFormatLeftBoundIndex + 1; inPlaceHolderString.length() - 1);