在 Mapping 里面,将 dynamic 参数设置成 strict 可以拒绝索引包含未知字段的文档。 此条 Tips 由 medcl 贡献。

SQL中使用某个字段like 'we%'过滤,同时对某个sum聚合求和,返回SQL异常

Elasticsearch | 作者 kewn21 | 发布于2019年01月30日 | 阅读数:2385

ES版本为6.5.4
 请求:
POST /_xpack/sql
{
"query" : "select os_version, sum(app_price) from user_event_log_1y where app_name like 'we%' group by os_version limit 20"
}
返回:
{
"error": {
"root_cause": [
{
"type": "sql_illegal_argument_exception",
"reason": "Cannot evaluate script for expression LikePattern[we%,\u0000]"
}
],
"type": "sql_illegal_argument_exception",
"reason": "Cannot evaluate script for expression LikePattern[we%,\u0000]"
},
"status": 500
}

上面sql中的sum(app_price),改成count(app_price),不报错,正常返回。
已邀请:

rochy - rochy_he

赞同来自: kewn21

这个是一个 ES 的 BUG,可以参考这个 issue:https://github.com/elastic/ela ... 36161
目前最新的 6.6 版本修复了该问题

要回复问题请先登录注册