MongoDB query $ nin exceeds BSON document size limit

I am making a simple query using Pymongo for a list of filenames:

db.FileAssets.find({'filename': {'$nin': filenames}}})

      

However, the request throws an error DocumentTooLarge

. The length of the list filenames

is 152098 and the size of the Python object is 1320856. Pymongo claims the query is 20791219 bytes, so my guess is that whatever MongoD does internally to do $ nin is overloading the document size. What is an alternative way to fulfill this query?

+3


source to share





All Articles