我创建的索引类别为:
> PUT categories {
"mappings": {
> "_doc": {
> "properties": {
> "assetId": {
> "type": "nested",
> "properties": {
> "Id": {
> "type": "long"
> }
> }
> }
> }
> }
},
"format":
"use_field_mapping",
"settings": {
> "number_of_shards": 1
}
}
然后将2个类别数据插入:-
POST categories/_doc/12301
{
"assetId": [{"Id": 1}, {"Id": 2}, {"Id": 3}]
}
POST categories/_doc/12302
{
"assetId": [{"Id": 1}, {"Id": 24}, {"Id": 25}]
}
然后以:-
查询GET _xpack/sql?format=json
{
"query":"select assetId.Id as Id from categories "
}
哪个返回此结果:
{"columns":[{"name":"Id","type":"long"}],"rows":[[1],[2],[3],[1],[24],[25]]}
我的问题是:如何获得单数组中的行结果,并且只有这样的不同值:
{"columns":[{"name":"Id","type":"long"}],"rows":[1,2,3,24,25] }
我尝试了GROUP_CONAT并且与众不同,但无法正常工作吗?