blob: f7690c96496d66f8b0b988b19ba82310c6627e70 (
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
|
// Multiple regular expressions using the same index
var t = db.jstests_regexc;
// $and using same index twice
t.drop();
t.ensureIndex({a: 1});
t.save({a: "0"});
t.save({a: "1"});
t.save({a: "10"});
assert.eq( 1, t.find({$and: [{a: /0/}, {a: /1/}]}).itcount() );
// implicit $and using compound index twice
t.drop();
t.ensureIndex({a: 1, b: 1});
t.save({a: "0", b: "1"});
t.save({a: "10", b: "10"});
t.save({a: "10", b: "2"});
assert.eq( 2, t.find({a: /0/, b: /1/}).itcount() );
// $or using same index twice
t.drop();
t.ensureIndex({a: 1});
t.save({a: "0"});
t.save({a: "1"});
t.save({a: "2"});
t.save({a: "10"});
assert.eq( 3, t.find({$or: [{a: /0/}, {a: /1/}]}).itcount() );
|