Pymongo : insert_many + unique index

One solution could be to use the ordered parameter of insert_many and set it to False (default is True):

my_collection.insert_many(to_insert, ordered=False)

From the PyMongo documentation:

ordered (optional): If True (the default) documents will be inserted on the server serially, in the order provided. If an error occurs all remaining inserts are aborted. If False, documents will be inserted on the server in arbitrary order, possibly in parallel, and all document inserts will be attempted.

Although, you would still have to handle an exception when all the documents couldn't be inserted.

Depending on your use-case, you could decide to either pass, log a warning, or inspect the exception.