I have a collection with a field (Renewal Date) that is not set for some documents. I tried to filter documents that are set Expiration Date between 2018-01-01 to 2022-05-17 and Renewal Date = NULL (Not Set). But the below-mentioned query is giving zero as a result.
db.documents.find(
{
entityId:"10803",
projectId:"3",
metaData:
{
$all: [
{$elemMatch : { key: "Expiration Date", value: {$lte: ISODate("2018-01-01T00:00:00.000Z"),$lte: ISODate("2022-05-17T00:00:00.000Z")} }},
{$elemMatch : { key: "Renewal Date", value: { $exists: false }}}
]
}}
).count()