$and on array:: filter object for array field with and operator

I want to fetch documents which have sections elements as “AG1” and “OA1”.
from class atlas cluster.
In general, what is the query for matching only those documents which have sections(an array) set to two mentions field as elements only.
I mean like this.
{$and:[{“sections”:“OA1”},{“sections”:“AG1”}]} .But it is also fetching documents that have other elements in sections as well.

May be something like this should work :
{$and:[{$or:[{“sections.0”:“AG1”, “sections.1”:“OA1”}, {“sections.0”:“OA1”, “sections.1”:“AG1”}]}, {“sections”:{$size:2}}]}

1 Like