0

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()
David Makogon
  • 69,407
  • 21
  • 141
  • 189
  • Does this answer your question? [MongoDB: How to query for records where field is null or not set?](https://stackoverflow.com/questions/10591543/mongodb-how-to-query-for-records-where-field-is-null-or-not-set) – nimrod serok May 17 '22 at 15:30
  • I tried the way mentioned in this question. But that is not helped. Maybe I made some mistakes. https://stackoverflow.com/questions/10591543/mongodb-how-to-query-for-records-where-field-is-null-or-not-set – Damith Sriyantha May 17 '22 at 15:37
  • 1
    Please provide some sample data, so we could help – nimrod serok May 17 '22 at 15:54

0 Answers0