Hello @GURURAJ_U_K, welcome to the MongoDB community forum!
You can check for both the $ne: " "
and the $ne: null
conditions. For example, the query predicate can be:
{ $and: [ { year: { $ne: "" } }, { year: { $ne: null } } ] }
Your query filter can be checking based upon the data as well as the existence of the field. The check for null
covers the documents with the field value as null
as well as the non-existence of the field.
Is the year
field a number or a string? This also matters.
You may want to include some sample documents of the collection you are querying upon, in your reply (if you have any further questions).