Elasticsearch SQL doesn’t support the usage of scalar functions on top of nested fields in WHERE and ORDER BY clauses with the exception of comparison and logical operators 上述问题如何解决?
可以使用Elasticsearch的脚本查询来解决此问题。在脚本查询中,可以使用Painless脚本语言来执行任何所需的操作,包括对嵌套字段应用标量函数。以下是一个示例脚本查询,其中使用了标量函数:
POST /_search
{
"query": {
"script": {
"script": {
"source": "doc['nested_field.sub_field'].value * 2 > params.param1",
"params": {
"param1": 10
}
}
}
}
}
在此示例中,我们使用了标量函数,即乘以2,对嵌套字段进行比较。可以将此脚本查询用作替代方法,以避免使用Elasticsearch SQL中不支持的标量函数。
原文地址: https://www.cveoy.top/t/topic/6u0 著作权归作者所有。请勿转载和采集!