I have document structure as follows:
doc1:
{
"Tag": [
{
"Text": "tag1"
},
{
"Text": "tag2"
}
],
"Type:" : "type1",
}
doc2:
{
"Tag": [
{
"Text": "tag2"
},
{
"Text": "tag3"
}
],
"Type:" : "type1",
}
doc3:
{
"Tag": [
{
"Text": "tag5"
},
],
"Type:" : "type2",
}
And I want to achieve all tags of the documents (with given type) as a string with a query like for type 1, result would be:
[
"tag1",
"tag2",
"tag3"
]
I’ve tried some queries but couldn’t get any result, like
SELECT DISTINCT ARRAY tag.Text FOR tag IN b.Tag END AS tags
FROM `bucket1` AS b
WHERE b.Type == "type1"
Returns documents with this structure which I couldn’t join the returning arrays and I don’t know where to go from here:
[
{
"tags": [
"tag1",
"tag2"
]
},
{
"tags": [
"tag2",
"tag3"
]
}
]
Thank you.