2021-09-23 14:06:34 +03:00
|
|
|
// @tags: [
|
|
|
|
|
// assumes_read_concern_local,
|
2024-12-27 16:01:08 +04:00
|
|
|
// requires_getmore
|
2021-09-23 14:06:34 +03:00
|
|
|
// ]
|
|
|
|
|
|
2025-08-28 15:11:44 -04:00
|
|
|
let t = db.array_match4;
|
2014-02-05 14:05:09 -05:00
|
|
|
|
|
|
|
|
t.drop();
|
|
|
|
|
t.save({a: [1, 2]});
|
|
|
|
|
|
2025-08-28 15:11:44 -04:00
|
|
|
let query_gte = {a: {$gte: [1, 2]}};
|
2014-02-05 14:05:09 -05:00
|
|
|
|
|
|
|
|
//
|
|
|
|
|
// without index
|
|
|
|
|
//
|
|
|
|
|
|
2025-08-21 10:17:44 -07:00
|
|
|
assert.eq(1, t.find({a: [1, 2]}).count(), "$eq (without index)");
|
|
|
|
|
assert.eq(1, t.find(query_gte).itcount(), "$gte (without index)");
|
2014-02-05 14:05:09 -05:00
|
|
|
|
|
|
|
|
//
|
|
|
|
|
// with index
|
|
|
|
|
//
|
|
|
|
|
|
2020-11-17 13:45:05 +00:00
|
|
|
t.createIndex({a: 1});
|
2025-08-21 10:17:44 -07:00
|
|
|
assert.eq(1, t.find({a: [1, 2]}).count(), "$eq (with index)");
|
2014-02-05 14:05:09 -05:00
|
|
|
|
|
|
|
|
// display explain output (for index bounds)
|
2025-08-28 15:11:44 -04:00
|
|
|
let explain = t.find(query_gte).explain();
|
2025-08-21 10:17:44 -07:00
|
|
|
print("explain for " + tojson(query_gte, "", true) + " = " + tojson(explain));
|
2014-02-05 14:05:09 -05:00
|
|
|
|
|
|
|
|
// number of documents returned by indexes query should be consistent
|
|
|
|
|
// with non-indexed case.
|
2025-08-21 10:17:44 -07:00
|
|
|
assert.eq(1, t.find(query_gte).itcount(), "$gte (with index)");
|