N1QL analytics array [*] in SELECT

In the Query service N1QL, the following allows me to get a field value for all objects in an array.

SELECT some_array.some_field FROM …

The same N1QL in the analytics service does not work. What is my alternative besides UNNEST (which seems to exact a heavy performance penalty with my dataset).

Hi @brian.parker,
Please see the answers here.
Basically you can get the same result using the function ARRAY_STAR:
SELECT ARRAY_STAR(some_array).some_field FROM ...

https://docs.couchbase.com/server/current/analytics/8_builtin.html#array_star

It works thanks…and the turnaround of getting this answer so quickly is very much appreciated!! I saw that function before, but the description of the function in the documentation did not lead me to believe it would satisfy this use case. Now that I read it again carefully, it makes sense.

1 Like