diff options
author | Randolph Tan <randolph@10gen.com> | 2014-01-14 14:09:42 -0500 |
---|---|---|
committer | Randolph Tan <randolph@10gen.com> | 2014-02-28 16:26:33 -0500 |
commit | 5595b945603b0712c537787e31e6da661c424fee (patch) | |
tree | 90945ee3fe4931032f3af2d397bb755fbf5d30ef /jstests/core/geo_2d_explain.js | |
parent | cd62080dcb036e83f8fca6d68d9bcab67bf7a21c (diff) | |
download | mongo-5595b945603b0712c537787e31e6da661c424fee.tar.gz |
SERVER-12127 migrate js tests to jscore suite when not related to writes
Moved test jstest/[a-i].js -> jstests/core/ and made changes to comply with write command api
Diffstat (limited to 'jstests/core/geo_2d_explain.js')
-rw-r--r-- | jstests/core/geo_2d_explain.js | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/jstests/core/geo_2d_explain.js b/jstests/core/geo_2d_explain.js new file mode 100644 index 00000000000..8195642aabc --- /dev/null +++ b/jstests/core/geo_2d_explain.js @@ -0,0 +1,29 @@ +var t = db.geo_2d_explain; + +t.drop(); + +var n = 1000; + +// insert n documents with integer _id, a can be 1-5, loc is close to [40, 40] +t.drop() +t.ensureIndex({loc: "2d", _id: 1}) + +var x = 40; +var y = 40; +for (var i = 0; i < n; i++) { + // random number in range [1, 5] + var a = Math.floor(Math.random() * 5) + 1; + var dist = 4.0; + var dx = (Math.random() - 0.5) * dist; + var dy = (Math.random() - 0.5) * dist; + var loc = [x + dx, y + dy]; + t.save({_id: i, a: a, loc: loc}); +} + +var explain = t.find({loc: {$near: [40, 40]}, _id: {$lt: 50}}).explain(); + +print('explain = ' + tojson(explain)); + +assert.eq({}, explain.indexBounds); +assert.eq(explain.n, explain.nscannedObjects); +assert.lte(explain.n, explain.nscanned); |