We have a fairly large couchbase bucket that holds several document types, denoted by document prefixes. For example, we have some documents prefixed with device---[document name], some with market---[document name]). I want a list of all the existing prefixes. This is what I have tried so far:
select split(meta().id, "---")[0] as doc_type
from configs
group by doc_type;
I would hope for it to return something like
[
{
"doc_type": "device"
},
{
"doc_type": "market"
},
]
It fails with
"code": 4210,
"msg": "Expression must be a group key or aggregate: (split((meta(`docsis_configs`).`id`), \"---\")[0])",
I'm not sure how to solve the aggregation problem and have tried various things. However I suspect that even if I got that to work, this query would be very inefficient. Can someone help me with the aggregation? And is there a smarter way to do this? Or is this fine?