2021-09-23 14:06:34 +03:00
|
|
|
// @tags: [
|
|
|
|
|
// assumes_read_concern_local,
|
|
|
|
|
// ]
|
|
|
|
|
|
2014-02-05 14:05:09 -05:00
|
|
|
var t = db.array_match4;
|
|
|
|
|
|
|
|
|
|
t.drop();
|
|
|
|
|
t.save({a: [1, 2]});
|
|
|
|
|
|
2016-03-09 12:17:50 -05:00
|
|
|
var query_gte = {a: {$gte: [1, 2]}};
|
2014-02-05 14:05:09 -05:00
|
|
|
|
|
|
|
|
//
|
|
|
|
|
// without index
|
|
|
|
|
//
|
|
|
|
|
|
|
|
|
|
assert.eq(1, t.find({a: [1, 2]}).count(), '$eq (without index)');
|
|
|
|
|
assert.eq(1, t.find(query_gte).itcount(), '$gte (without index)');
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
// with index
|
|
|
|
|
//
|
|
|
|
|
|
2020-11-17 13:45:05 +00:00
|
|
|
t.createIndex({a: 1});
|
2014-02-05 14:05:09 -05:00
|
|
|
assert.eq(1, t.find({a: [1, 2]}).count(), '$eq (with index)');
|
|
|
|
|
|
|
|
|
|
// display explain output (for index bounds)
|
|
|
|
|
var explain = t.find(query_gte).explain();
|
|
|
|
|
print('explain for ' + tojson(query_gte, '', true) + ' = ' + tojson(explain));
|
|
|
|
|
|
|
|
|
|
// number of documents returned by indexes query should be consistent
|
|
|
|
|
// with non-indexed case.
|
2020-01-24 15:53:43 -05:00
|
|
|
assert.eq(1, t.find(query_gte).itcount(), '$gte (with index)');
|