I want to delete all geospacial fields that are NaN so I can properly index my MongoDB.
How do I find all documents that have this though?
db.collection.find( { field: {$not: { $type: 1 } } })
won't work since NaN is of type Number.
I want to delete all geospacial fields that are NaN so I can properly index my MongoDB.
How do I find all documents that have this though?
db.collection.find( { field: {$not: { $type: 1 } } })
won't work since NaN is of type Number.
Solution for PyMongo:
or
FYI: I ran into this issue because
mongoexport
(mongo 3.0.7) wroteNaN
into the JSON files it created. This appears to have been addressed in 3.3.5.So again using PyMongo and in a similar boat, you can replace
NaN
with Python'sNone
, whichmongoexport
will convert to JSON validnull
:actually works although I couldn't find any documentation on it