PyMongo unset empty string fields in large collection with many fields

Viewed 24

I have a MongoDB collection, currently with 24,223,107 documents (although I'm loading it and it will be closer to 100 million documents), each with around 600 fields.

In the interest of making this collection more usable, I am hoping to remove all fields containing empty strings (of which there are many) per document.

Is there a functional way to do this from PyMongo? I know that I can $unset specific fields (and potentially do this conditionally), just looking for the most efficient way to unset any empty string field across the entire collection, presumably in an aggregation pipeline.

0 Answers
Related