E11000 duplicate

I have a compound index to avoid duplicate but sometime one of the compount index is null. How can I allow to save null in a compount index to avoid E11000 error.

I would take a look at https://docs.mongodb.com/manual/core/index-partial/. I have not tested that with unique index but I feel that it should work be having a condition that exclude documents with null.

Let us know how it goes.