summaryrefslogtreecommitdiff
path: root/jstests/aggregation/bugs/server14421.js
blob: 3d7386feaa7d7ccc36417424b752acc7ec147c8b (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
41
42
43
// SERVER-14421 minDistance for $geoNear aggregation operator
// @tags: [
//   sbe_incompatible,
// ]
(function() {
'use strict';
var coll = db.mindistance;
coll.drop();
assert.commandWorked(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();
}());