Query N1QL for nested Object

Hello,

I have documents of following struct:
“Name”: Doc1,
“Tag”: [
{
“Text”: “a”
},
]

“Name”: Doc2,
“Tag”: [
{
“Text”: “b”
},
]

“Name”: Doc3,
“Tag”: [
{
“Text”: “c”
},
]

“Name”: Doc4,
“Tag”: [
{
“Text”: “a”
},
{
“Text”: “b”
}
],

Now I would like to make a query to get all docs which contain a or b -> so result should be 3 (Doc1, 2, 4)

I have really tried a lot (UNNEST, WITHIN, IN, ANY …) I could not get the correct result.

Last try was:

SELECT
*
FROM avl_dal_document_store_test
UNNEST Tag AS item
WHERE item.Text IN [‘a’, ‘b’]

but did not deliver the desired result as well :slight_smile: Any ideas? TY

SELECT *
FROM avl_dal_document_store_test
WHERE ANY v IN TagSATISFIES v.Text IN ["a","b"] END;

Thank you for the reply but does not work either → no results
i also tried
SELECT Tag as v
FROM avl_dal_document_store_test
WHERE ANY v IN Text SATISFIES v IN [“a”,“b”] END;
with no success

Got it working now! Thank you for the query, after some modifying i came to:

SELECT *
FROM avl_dal_document_store_test
WHERE ANY v IN Tag SATISFIES v.Text IN [“a”, “c”] END;

1 Like