悟空,拿我的打狗棒来

es-sql查询如何计算一个值为数组的字段,计算该数组的元素个数

Elasticsearch | 作者 shuoyun | 发布于2020年10月10日 | 阅读数:3119

PowerShell下如下的运行语句(出于隐私目的,没写出ip和端口):
 curl.exe -X GET "x.x.x.x:x/_sql" -H 'Content-Type: application/json' -d"SELECT none_pay_course_list FROM user_portrayal where uc_id=4001464" ;
 
运行结果:
{"took":33,"timed_out":false,"_shards":{"total":6,"successful":6,"skipped":0,"failed":0},"hits":{"total":{"value":1,"relation":"eq"},"max_score":0.0,"hits":[{"_index":"user_portrayal","_type":"_doc","_id":"4001464_1","_score":0.0,"_source":{"none_pay_course_list":[{"course":"11_30"},{"course":"11_37"},{"course":"11_23"},{"course":"11_38"}]}}]}}
 
提出问题:
如何改写运行语句,使得能够计算出none_pay_course_list的数组中元素个数。此处目测正确答案为4.(本人试过了split,count,size,length等各种各样的组合,但是还是未得到正确的答案,望得到解答,十分感谢)
已邀请:

Charele - Cisco4321

赞同来自:

想知道你里面的none_pay_course_list是什么类型的?
 
我试了下,sql好像不支持数组啊

sql.png

 

locatelli

赞同来自:

EQL本身不支持array:https://www.elastic.co/guide/e ... tions

要回复问题请先登录注册