SELECT i.categories
FROM default a UNNEST a.item i
WHERE ANY AND EVERY s IN i.specs SATISFIES s IN ["spec1","spec2"] END;
ANY or SOME, EVERY, and ANY AND EVERY or SOME AND EVERY
Range predicates (ANY or SOME, EVERY, and ANY AND EVERY or SOME AND EVERY) allow you to test a boolean condition over the elements or attributes of a collection or object(s). They each evaluate to a boolean value.
ANY or SOME is TRUE if the collection is non-empty and at least one element matches.
EVERY is TRUE if the collection is empty, or if the collection is non-empty and every element matches.
ANY AND EVERY or SOME AND EVERY is TRUE if the collection is non-empty and every element matches.
Same query can be used for both cases and change query parameter $spec to [“spec1”] or [“spec1”,“spec2”]
SELECT i.categories
FROM default a UNNEST a.item i
WHERE ANY AND EVERY s IN i.specs SATISFIES s IN $spec END;