Use Compound and Range operator together in Atlas Search

I have 3 fields indexed in Atlas Search from a mongodb collection of documents:

  1. deleted
  2. duplicate
  3. publication_date

I am trying to query Atlas Search using the aggregate method and i need to filter out documents with deleted and duplicate set to true and at the same time bring only documents that have publication date with a range i specify.

I tried doing this:

{
   compound:{
     filter:[{
       equals:{
         value:false,
         path:"deleted"
       },
       equals:{
         value:false,
         path:"duplicate"
       }
     }
    ]
   },
   range:{
     path:'publication_date',
     gte:ISODate("2021-04-01T00:00:00Z"),
     lte:ISODate("2021-10-11T19:11:16.1928297Z")
   }
 }

But i get an error that i cant use compound and range together. I need to use compound because, i need to more must and must not criteria.

Both of them are working separately, but i need a way to combine them.

Any help is appreciated.

I think your query would look something like the below. Try it out and let me know if it works for you! Thanks

1 Like

A post was split to a new topic: PyMongo Cant connect to MongoDB Atlas from Azure Container Instance