File: covered_index_geo_1.js

package info (click to toggle)
mongodb 1%3A2.4.10-5
  • links: PTS, VCS
  • area: main
  • in suites: jessie-kfreebsd
  • size: 82,464 kB
  • sloc: cpp: 740,225; ansic: 152,098; sh: 13,820; python: 11,864; makefile: 1,012; perl: 922; pascal: 617; java: 452; lisp: 222; asm: 174
file content (18 lines) | stat: -rw-r--r-- 890 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
var coll = db.getCollection("covered_geo_1")
coll.drop()

coll.insert({_id : 1, loc : [ 5 , 5 ], type : "type1"})
coll.insert({_id : 2, loc : [ 6 , 6 ], type : "type2"})
coll.insert({_id : 3, loc : [ 7 , 7 ], type : "type3"})

coll.ensureIndex({loc : "2d", type : 1});

var plan = coll.find({loc : [ 6 , 6 ]}, {loc:1, type:1, _id:0}).hint({loc:"2d", type:1}).explain();
assert.eq(false, plan.indexOnly, "geo.1.1 - indexOnly should be false on a non covered query")
assert.neq(0, plan.nscannedObjects, "geo.1.1 - nscannedObjects should not be 0 for a non covered query")

var plan = coll.find({loc : [ 6 , 6 ]}, {type:1, _id:0}).hint({loc:"2d", type:1}).explain();
assert.eq(false, plan.indexOnly, "geo.1.2 - indexOnly should be false on a non covered query")
assert.neq(0, plan.nscannedObjects, "geo.1.2 - nscannedObjects should not be 0 for a non covered query")

print("all tests passed")