-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Description
我的版本是Elasticsearch8.17.4,当前其他命令都是正常执行的,环境是没有问题的,但是执行这段加了terms的SQL语句后报错,请问下与版本号有关系么还是有其它特殊要求?
附录相关环境和错误信息供参考,谢谢。
1、执行控制台错误日志如下:
----执行SQL
SELECT t.statis_date AS CCOL1,SUM(t.amount2) AS CCOL2 FROM biz1d8vmyfwndbmrf9b7da2fohr5gh t WHERE 1=1 GROUP BY terms(substring(t.statis_date,0,8),size=1000,alias='statis_date') ORDER BY statis_date ASC
----执行错误日志
Exception in thread "main" java.lang.Exception: {"error":{"root_cause":[{"type":"script_exception","reason":"compile error","script_stack":["... urn substring_1756669309;; return substring_175666 ..."," ^---- HERE"],"script":"def substring_1756669309 = doc['statis_date'].value.substring(0,8);return substring_1756669309;; return substring_1756669309","lang":"painless","position":{"offset":95,"start":70,"end":120}}],"type":"search_phase_execution_exception","reason":"all shards failed","phase":"query","grouped":true,"failed_shards":[{"shard":0,"index":"biz1d8vmyfwndbmrf9b7da2fohr5gh","node":"3FWMd4E_Qo6EzA-jfaXXJg","reason":{"type":"script_exception","reason":"compile error","script_stack":["... urn substring_1756669309;; return substring_175666 ..."," ^---- HERE"],"script":"def substring_1756669309 = doc['statis_date'].value.substring(0,8);return substring_1756669309;; return substring_1756669309","lang":"painless","position":{"offset":95,"start":70,"end":120},"caused_by":{"type":"illegal_argument_exception","reason":"unexpected token [';'] was expecting one of []."}}}]},"status":400}
at com.seeri.ribot.common.util.EsSqlHttpServiceImpl.doPost(EsSqlHttpServiceImpl.java:997)
2、 biz1d8vmyfwndbmrf9b7da2fohr5gh的索引信息
{
"mappings": {
"properties": {
"$kettleId$": {
"type": "long",
"null_value": 0
},
"amount2": {
"type": "double",
"null_value": 0
},
"city_name": {
"type": "text",
"fields": {
"pinyin": {
"type": "text",
"analyzer": "pinyin",
"fielddata": true
}
},
"analyzer": "keyword",
"fielddata": true
},
"statis_date": {
"type": "text",
"fields": {
"pinyin": {
"type": "text",
"analyzer": "pinyin",
"fielddata": true
}
},
"analyzer": "keyword",
"fielddata": true
}
}
}
}
3、biz1d8vmyfwndbmrf9b7da2fohr5gh中的数据示例
{
"_index": "biz1d8vmyfwndbmrf9b7da2fohr5gh",
"_id": "2",
"_score": 1,
"_source": {
"city_name": "CITY2",
"amount2": 1002,
"statis_date": "2025-09-02 00:00:00",
"$kettleId$": 2
}
},