I have a document as below, where person is an array of objects, which itself has keys which is an array. If entry in keys=“1234” and (name=“jack” or name=“jones”) then document satisfying that condition needs to be returned. So in the below example, Doc1 satisfies the condition and should be returned but not Doc2.
SELECT ...
FROM ...
WHERE ANY p IN person
SATISFIES
p.name IN ["jack","jones"]
AND ANY k IN p.`keys` -- must quote reserved word "keys"
SATISFIES
k = "1234"
END
END
If you want two conditions - jack+1234 & jones+1234 you need to simply duplicate and AND the conditions:
Try:
SELECT ...
FROM ...
WHERE ANY p IN person
SATISFIES
p.name = "jack"
AND ANY k IN p.`keys`
SATISFIES
k = "1234"
END
END
AND ANY p IN person
SATISFIES
p.name = "jones"
AND ANY k IN p.`keys`
SATISFIES
k = "1234"
END
END
If you mean, jack+jones and any key (even if not associated with either jack or jones) is 1234, then try:
SELECT ...
FROM ...
WHERE ANY p IN person
SATISFIES
p.name = "jack"
END
AND ANY p IN person
SATISFIES
p.name = "jones"
END
AND ANY p IN PERSON
SATISFIES
ANY k IN p.`keys`
SATISFIES
k = "1234"
END
END
If you mean jack+jones and one of them (but not necessarily both) have an associated key 1234, try:
SELECT ...
FROM ...
WHERE ANY p IN person
SATISFIES
p.name = "jack"
END
AND ANY p IN person
SATISFIES
p.name = "jones"
END
AND ANY p IN PERSON
SATISFIES
p.name IN ["jack","jones"]
ANY k IN p.`keys`
SATISFIES
k = "1234"
END
END