File: geo_circle2a.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 (37 lines) | stat: -rw-r--r-- 1,686 bytes parent folder | download | duplicates (3)
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
// From SERVER-2381 
// Tests to make sure that nested multi-key indexing works for geo indexes and is not used for direct position
// lookups

var coll = db.geo_circle2a;
coll.drop();
coll.insert({ p : [1112,3473], t : [{ k : 'a', v : 'b' }, { k : 'c', v : 'd' }] })
coll.ensureIndex({ p : '2d', 't.k' : 1 }, { min : 0, max : 10000 })

// Succeeds, since on direct lookup should not use the index
assert(1 == coll.find({p:[1112,3473],'t.k':'a'}).count(), "A")
// Succeeds and uses the geo index
assert(1 == coll.find({p:{$within:{$box:[[1111,3472],[1113,3475]]}}, 't.k' : 'a' }).count(), "B")


coll.drop()
coll.insert({ point:[ 1, 10 ], tags : [ { k : 'key', v : 'value' }, { k : 'key2', v : 123 } ] })
coll.insert({ point:[ 1, 10 ], tags : [ { k : 'key', v : 'value' } ] })

coll.ensureIndex({ point : "2d" , "tags.k" : 1, "tags.v" : 1 })

// Succeeds, since should now lookup multi-keys correctly
assert(2 == coll.find({ point : { $within : { $box : [[0,0],[12,12]] } } }).count(), "C") 
// Succeeds, and should not use geoindex
assert(2 == coll.find({ point : [1, 10] }).count(), "D")
assert(2 == coll.find({ point : [1, 10], "tags.v" : "value" }).count(), "E")
assert(1 == coll.find({ point : [1, 10], "tags.v" : 123 }).count(), "F")


coll.drop()
coll.insert({ point:[ 1, 10 ], tags : [ { k : { 'hello' : 'world'}, v : 'value' }, { k : 'key2', v : 123 } ] })
coll.insert({ point:[ 1, 10 ], tags : [ { k : 'key', v : 'value' } ] })

coll.ensureIndex({ point : "2d" , "tags.k" : 1, "tags.v" : 1 })

// Succeeds, should be able to look up the complex element
assert(1 == coll.find({ point : { $within : { $box : [[0,0],[12,12]] } }, 'tags.k' : { 'hello' : 'world' } }).count(), "G")