How to query documents which are arrays

Hello all,

I’m a novice Couchbase user and I have a bucket which I’ve created that contains documents which are actually arrays in the form of:

{
	"key": [
		{
			"data1": "somedata1"
		},
		{
			"data2": "somedata2"
		}
	]
}

I want to query these documents via N1QL statements and have yet to find a solution to how to do this properly. More specifically, I would like to select fields inside each sub-document that is in an array of a certain key. For example, I would like to access: key.[1].data2 or key.[0].data1

How should I do it?
Thanks in advance, Oren.

If you want access them key[0].data1 or key[1].data2

If you want use in WHERE clause
ANY v FOR v IN key SATISIFIES v.data1 = “xyz” END

Checkout article N1QL Array Functions | Searching in Arrays | Couchbase by @johan_larson

Checkout more details for array indexing https://developer.couchbase.com/documentation/server/current/n1ql/n1ql-language-reference/indexing-arrays.html
Making the most of your Arrays... with N1QL Array Indexing - The Couchbase Blog

https://developer.couchbase.com/documentation/server/current/n1ql/n1ql-language-reference/arrayfun.html

https://developer.couchbase.com/documentation/server/current/n1ql/n1ql-language-reference/collectionops.html