版本: 6.8-8.9
简而言之,当您尝试在 Elasticsearch 中对文本变量使用表达式时,会出现此错误。这是不允许的,因为文本字段没有针对需要基于数值或日期计算的操作进行优化。要解决此问题,您可以将字段类型更改为数值或日期类型,或者改用关键字字段。另外,您也可以使用脚本在执行操作之前将文本字段转换为数值或日期类型。
日志上下文 #
日志"Cannot use expression with text variable using"的类名是 ExpressionAggregationScript.java。 我们从 Elasticsearch 源代码中提取了以下内容,供那些寻求深入上下文的人参考:
// _value isn't used in script if specialValue == null
if (specialValue != null) {
if (value instanceof Number) {
specialValue.setValue(((Number) value).doubleValue());
} else {
throw new GeneralScriptException("Cannot use expression with text variable using " + exprScript);
}
}
}
};
}





