On the main level, documents in ArangoDB are JSON objects. The JSON you're showing above in a JSON array, so it won't be accepted as is as a document.
What you can do is wrap the above JSON in an object attribute, for example data
:
{"data":[[{"QID":1,"AID":1},{"SubAID":[]}],[{"QID":2,"AID":1},{"SubAID":[2,4]}],[{"QID":3,"AID":1},{"SubAID":[]}],{"MaxArea":"90","MinArea":"16"}]}
Regarding querying the data: it looks like data is an array containing arrays and an object. Inside the arrays there is an object with attributes QID
and AID
at array position 0, and an object containing SubAid
at array position 1.
If that's true for all data, the a query like as follows should find the documents that a QID
value of 2
:
/* iterate over all documents in collection */
FOR doc IN collection
LET s = (
/* iterate over embedded attribute "data */
FOR sub IN doc.data
/* look at QID at array position 0 */
FILTER sub[0].QID == 2
/* first match is sufficient */
LIMIT 1
/* return SubAID value from array position 1 */
RETURN sub[1].SubAID
)
/* only return documents with a match */
FILTER LENGTH(s) > 0
/* return first result from subquery (subquery result is always an array) */
RETURN s[0]