this is related to post: N1QL analytics array [*] in SELECT but a slightly different scenario
In the Query service N1QL, the following allows me to get a field value for all objects in a nested array within a nested array.
SELECT some_array[ * ]
.some_nested_array[ * ]
.some_field FROM …
In the analytics service, can I use ARRAY_STAR in a similar manner and if so how (below is erroring out for me when I tried)?
SELECT ARRAY_STAR(some_array.some_nested_array.some_field)) FROM …
I tried a few variations of nested ARRAY_STAR calls too but could not get anything to work.
Have you tried nesting ARRAY_STAR() calls as follows:
LET input_array = [
{ “a”: { “b”: “v1” } },
{ “a”: { “b”: “v2” } }
]
SELECT ARRAY_STAR(ARRAY_STAR(input_array).a).b
Returns: { “b”: [ “v1”, “v2” ] }
If you have nested arrays then also try ARRAY_FLATTEN() function to flatten them:
LET input_array = [
{ “a”: [ { “b”: “v1” }, { “b”: “v3” } ] },
{ “a”: [ { “b”: “v2” }, { “b”: “v4” } ] }
]
SELECT ARRAY_STAR(ARRAY_FLATTEN(ARRAY_STAR(input_array).a,1)).b
Returns: { “b”: [ “v1”, “v3”, “v2”, “v4” ] }
If none of these work, then please post some sample data and the expected result, so we could take another look.