3

I have a bunch of documents that look like this

{
  "coordinates": [[1, 2], [nan, nan]  ]
}

I would like to filter and find all documents where one of those arrays contains nan values like in the example.

styvane
  • 49,879
  • 15
  • 119
  • 132
iDontKnowBetter
  • 393
  • 1
  • 5
  • 19

2 Answers2

1

$elemMatch with $in query will also filter, check below query

db.collection.find({"coordinates":{"$elemMatch":{"$elemMatch":{"$in":["nan"]}}}})
Yogesh
  • 7,037
  • 4
  • 28
  • 50
0

If you always have pairs in your inner arrays then

db.yourColl.find({coordinates: [NaN, NaN]})

should do the job

DAXaholic
  • 28,212
  • 5
  • 58
  • 67