I have a collection with large number of documents (~100Million). I want to get documents which don't exist in the collection from the list of queries I provided. Example:
query_user_ids = ["32432", "32433", "32434", "32435"]
document = {"_id": "xxxx", "user_id": "32433", "details": "xxxx"}
user_id has unique index on it
I want to query which user_ids are not present in the collection. So assuming user_id 32434 and 32435 do not exist, when I query the collection with this list of ids, I should get the response ["32434", "32435"]
Right now, I am just looping over the user_ids and calling find_one to check if document with user_id exists or not, but I suspect this is slowing down the operation. Is there a way I can do it by directly passing in the list of ids.
I am using PyMongo for querying.