summaryrefslogtreecommitdiff
path: root/jstests/aggregation/bugs/server14421.js
blob: b6701546e3d6fa7a6f682efea32ce427f89eae7c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
// SERVER-14421 minDistance for $geoNear aggregation operator
(function() {
'use strict';
var coll = db.mindistance;
coll.drop();
assert.writeOK(coll.insert([
    {_id: 0, loc: {type: "Point", coordinates: [0, 0]}},
    {_id: 1, loc: {type: "Point", coordinates: [0, 0.01]}}
]));
var response = coll.createIndex({loc: "2dsphere"});
assert.eq(response.ok, 1, "Could not create 2dsphere index");
var results = coll.aggregate([{
    $geoNear: {
        minDistance: 10000,
        spherical: true,
        distanceField: "distance",
        near: {type: "Point", coordinates: [0, 0]}
    }
}]);
assert.eq(results.itcount(), 0);
results = coll.aggregate([{
    $geoNear: {
        minDistance: 1,
        spherical: true,
        distanceField: "distance",
        near: {type: "Point", coordinates: [0, 0]}
    }
}]);
assert.eq(results.itcount(), 1);
results = coll.aggregate([{
    $geoNear: {
        minDistance: 0,
        spherical: true,
        distanceField: "distance",
        near: {type: "Point", coordinates: [0, 0]}
    }
}]);
assert.eq(results.itcount(), 2);
coll.drop();
}());