On previous versions of the server, if the result set is empty from a geoNear command, avgDistance was NaN. The following is using 3.0.7:
{
"results" : [ ],
"stats" : {
"nscanned" : 12,
"objectsLoaded" : 4,
"avgDistance" : NaN,
"maxDistance" : 0,
"time" : 0
},
"ok" : 1
}
On 3.2.0-rc0, avgDistance is missing:
{
"waitedMS" : NumberLong(0),
"results" : [ ],
"stats" : {
"nscanned" : 10,
"objectsLoaded" : 4,
"maxDistance" : 0,
"time" : 1
},
"ok" : 1
}
It seems that this is a bug as maxDistance is included even though it's 0.