Skip to content

Commit

Permalink
additional test for geoindex
Browse files Browse the repository at this point in the history
  • Loading branch information
Greg Studer committed Jan 28, 2011
1 parent 2cf0b20 commit 7fa627b
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion jstests/geo_circle2a.js
@@ -1,4 +1,6 @@
// From SERVER-2381
// Tests to make sure that nested multi-key indexing works for geo indexes and is not used for direct position
// lookups

db.test.drop()
db.test.insert({ p : [1112,3473], t : [{ k : 'a', v : 'b' }, { k : 'c', v : 'd' }] })
Expand All @@ -18,8 +20,17 @@ db.test.ensureIndex({ point : "2d" , "tags.k" : 1, "tags.v" : 1 })

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


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

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

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

0 comments on commit 7fa627b

Please sign in to comment.