N1QL nested array issue

{
“Filters”: [
{
“categotyId”: “123”,
“enabled”: true,
“items”: [
{
“alt”: “apple image alt”,
“displayName”: “ABC”,
“enabled”: true,
“imageName”: “ABC”
}
],
“key”: “manufacturer”,
“ranking”: “100”
}
]
}

I have the above document in couch base. I want to fetch this document and include only the items which have enabled = true.

Here the arrays are nested. Filters is an array with each object having enabled property.
 Each object in filters has items array and each object in items array has again enabled property.

SELECT ARRAY v FOR v IN filters WHEN v.enabled= true end as Filters FROM bucket use keys “documentId”

I have the above query, but it filters only one level

SELECT ARRAY OBJECT_CONCAT(v,{"items": ARRAY iv FOR iv IN v.items WHEN iv.enabled = true END}) FOR v IN filters WHEN v.enabled= true end as Filters 
FROM bucket use keys "documentId";
1 Like

thanks, it solved my prob.