How to offset the children nodes results

Tutorial for N1QL has this example: https://query-tutorial.couchbase.com/tutorial/#15
That example shows how to offset or limit children node results.

I am trying to achieve the same in Couchbase Analytics, but unsuccessful as array[start_index:end_index] syntax is not supported.

Could you, please, recommend how this can be achieved in Analytics query. Thanks

Question on stackoverflow: https://stackoverflow.com/questions/54046129/offset-results-of-children-nodes-from-n1ql-analytics-query.

@evgeniya.bell
the array slicing syntax indeed isn’t supported yet - but it will be soon.
For now you can replace this syntax with a nested subquery.
The equivalent of

SELECT VALUE ['a','b','c','d'][1:3]

would be

SELECT VALUE v FROM ['a','b','c','d'] v LIMIT 2 OFFSET 1

So, instead of getting the array entries from 1 to 3 (not including 3) you can get 2 entries, starting with the entry 1.

This query does not work for the children nodes array. My data structure is something similar to:
[
{
“parentId”:1,
"children:[‘a’,‘b’,‘c’,‘d’]
},
{
“parentId”:2,
"children:[‘a’,‘b’,‘c’,‘d’]
}
]

The task is to select parentId node and children node with OFFSET 2. Query that you suggested will work to offset parent array, but not children array. Is there any other way to achieve this? I would prefer stick with Analytics and not Query, but the ability to limit results from children array is essential to the task. Thank you

I saw the response at stackowerflow. That query works. Thank you.

Offset doesn’t work in analytics - what do you use instead?

Currently OFFSET is a sub-clause of the LIMIT clause in Analytics, so you need to have a LIMIT clause in order to use OFFSET:

SELECT ... 
FROM ...
LIMIT limit_value OFFSET offset_value