summaryrefslogtreecommitdiff
path: root/jstests/noPassthroughWithMongod
diff options
context:
space:
mode:
authorJames Wahlin <james@mongodb.com>2018-10-01 16:05:08 -0400
committerJames Wahlin <james@mongodb.com>2018-10-02 09:56:37 -0400
commitf7ddb89c8caf438781de9191d690d03f711b63fe (patch)
tree9244266869d8c17de23d5e0c817a2fddc2bc849a /jstests/noPassthroughWithMongod
parent5a6ee566f608c46654133de17a4e8bb3464d680d (diff)
downloadmongo-f7ddb89c8caf438781de9191d690d03f711b63fe.tar.gz
SERVER-37188 Rename "All Paths" index to "Wildcard" index
Diffstat (limited to 'jstests/noPassthroughWithMongod')
-rw-r--r--jstests/noPassthroughWithMongod/wildcard_and_text_indexes.js (renamed from jstests/noPassthroughWithMongod/all_paths_and_text_indexes.js)26
-rw-r--r--jstests/noPassthroughWithMongod/wildcard_index_basic_index_bounds.js (renamed from jstests/noPassthroughWithMongod/all_paths_basic_index_bounds.js)28
-rw-r--r--jstests/noPassthroughWithMongod/wildcard_index_cached_plans.js (renamed from jstests/noPassthroughWithMongod/all_paths_cached_plans.js)8
-rw-r--r--jstests/noPassthroughWithMongod/wildcard_index_collation.js (renamed from jstests/noPassthroughWithMongod/all_paths_collation.js)24
-rw-r--r--jstests/noPassthroughWithMongod/wildcard_index_covered_queries.js (renamed from jstests/noPassthroughWithMongod/all_paths_covered_queries.js)20
-rw-r--r--jstests/noPassthroughWithMongod/wildcard_index_hint.js (renamed from jstests/noPassthroughWithMongod/all_paths_hint.js)11
-rw-r--r--jstests/noPassthroughWithMongod/wildcard_index_multikey.js (renamed from jstests/noPassthroughWithMongod/all_paths_index_multikey.js)54
-rw-r--r--jstests/noPassthroughWithMongod/wildcard_index_nonblocking_sort.js (renamed from jstests/noPassthroughWithMongod/all_paths_index_nonblocking_sort.js)6
-rw-r--r--jstests/noPassthroughWithMongod/wildcard_index_partial_index.js (renamed from jstests/noPassthroughWithMongod/all_paths_partial_index.js)8
-rw-r--r--jstests/noPassthroughWithMongod/wildcard_index_return_key.js (renamed from jstests/noPassthroughWithMongod/all_paths_return_key.js)2
-rw-r--r--jstests/noPassthroughWithMongod/wildcard_index_validindex.js (renamed from jstests/noPassthroughWithMongod/all_paths_validindex.js)48
11 files changed, 114 insertions, 121 deletions
diff --git a/jstests/noPassthroughWithMongod/all_paths_and_text_indexes.js b/jstests/noPassthroughWithMongod/wildcard_and_text_indexes.js
index 21f6a149aa9..58677209ddf 100644
--- a/jstests/noPassthroughWithMongod/all_paths_and_text_indexes.js
+++ b/jstests/noPassthroughWithMongod/wildcard_and_text_indexes.js
@@ -17,13 +17,13 @@
const assertArrayEq = (l, r) => assert(arrayEq(l, r), tojson(l) + " != " + tojson(r));
- const coll = db.all_paths_and_text_indexes;
+ const coll = db.wildcard_and_text_indexes;
coll.drop();
- // Runs a single allPaths query test, confirming that an indexed solution exists, that the $**
+ // Runs a single wildcard query test, confirming that an indexed solution exists, that the $**
// index on the given 'expectedPath' was used to answer the query, and that the results are
// identical to those obtained via COLLSCAN.
- function assertAllPathsQuery(query, expectedPath) {
+ function assertWildcardQuery(query, expectedPath) {
// Explain the query, and determine whether an indexed solution is available.
const explainOutput = coll.find(query).explain("executionStats");
const ixScans = getPlanStages(explainOutput.queryPlanner.winningPlan, "IXSCAN");
@@ -43,9 +43,9 @@
assert.commandWorked(
db.adminCommand({setParameter: 1, internalQueryAllowAllPathsIndexes: true}));
try {
- // Build an allPaths index, and verify that it can be used to query for the field '_fts'.
+ // Build a wildcard index, and verify that it can be used to query for the field '_fts'.
assert.commandWorked(coll.createIndex({"$**": 1}));
- assertAllPathsQuery({_fts: {$gt: 0, $lt: 4}}, '_fts');
+ assertWildcardQuery({_fts: {$gt: 0, $lt: 4}}, '_fts');
// Perform the tests below for simple and compound $text indexes.
for (let textIndex of[{'$**': 'text'}, {a: 1, '$**': 'text'}]) {
@@ -54,7 +54,7 @@
// Confirm that the $** index can still be used to query for the '_fts' field outside of
// a $text query.
- assertAllPathsQuery({_fts: {$gt: 0, $lt: 4}}, '_fts');
+ assertWildcardQuery({_fts: {$gt: 0, $lt: 4}}, '_fts');
// Confirm that $** does not generate a candidate plan for $text search, including cases
// when the query filter contains a compound field in the $text index.
@@ -80,13 +80,13 @@
assert.eq(explainOut.queryPlanner.rejectedPlans.length, 0);
assert.eq(explainOut.executionStats.nReturned, 3);
- const textOrAllPaths = getPlanStages(explainOut.queryPlanner.winningPlan, "OR").shift();
- assert.eq(textOrAllPaths.inputStages.length, 2);
- const textBranch = (textOrAllPaths.inputStages[0].stage === "TEXT" ? 0 : 1);
- const allPathsBranch = (textBranch + 1) % 2;
- assert.eq(textOrAllPaths.inputStages[textBranch].stage, "TEXT");
- assert.eq(textOrAllPaths.inputStages[allPathsBranch].stage, "IXSCAN");
- assert.eq(textOrAllPaths.inputStages[allPathsBranch].keyPattern, {$_path: 1, _fts: 1});
+ const textOrWildcard = getPlanStages(explainOut.queryPlanner.winningPlan, "OR").shift();
+ assert.eq(textOrWildcard.inputStages.length, 2);
+ const textBranch = (textOrWildcard.inputStages[0].stage === "TEXT" ? 0 : 1);
+ const wildcardBranch = (textBranch + 1) % 2;
+ assert.eq(textOrWildcard.inputStages[textBranch].stage, "TEXT");
+ assert.eq(textOrWildcard.inputStages[wildcardBranch].stage, "IXSCAN");
+ assert.eq(textOrWildcard.inputStages[wildcardBranch].keyPattern, {$_path: 1, _fts: 1});
// Drop the index so that a different text index can be created.
assert.commandWorked(coll.dropIndex("textIndex"));
diff --git a/jstests/noPassthroughWithMongod/all_paths_basic_index_bounds.js b/jstests/noPassthroughWithMongod/wildcard_index_basic_index_bounds.js
index 9eef97a7da4..54fdcdfba58 100644
--- a/jstests/noPassthroughWithMongod/all_paths_basic_index_bounds.js
+++ b/jstests/noPassthroughWithMongod/wildcard_index_basic_index_bounds.js
@@ -17,7 +17,7 @@
const assertArrayEq = (l, r) => assert(arrayEq(l, r));
- const coll = db.all_paths_index_bounds;
+ const coll = db.wildcard_index_bounds;
coll.drop();
// Template document which defines the 'schema' of the documents in the test collection.
@@ -82,7 +82,7 @@
// been indexed based on the spec; this function will confirm that only the appropriate paths
// are present in the $** index. Finally, for each match expression it will perform a rooted-$or
// with one predicate on each expected path, and a rooted $and over all predicates and paths.
- function runAllPathsIndexTest(keyPattern, pathProjection, expectedPaths) {
+ function runWildcardIndexTest(keyPattern, pathProjection, expectedPaths) {
assert.commandWorked(coll.dropIndexes());
assert.commandWorked(coll.createIndex(
keyPattern, pathProjection ? {wildcardProjection: pathProjection} : {}));
@@ -202,24 +202,24 @@
try {
// Test a $** index that indexes the entire document.
- runAllPathsIndexTest({'$**': 1}, null, ['a', 'b.c', 'b.d.e', 'b.f']);
+ runWildcardIndexTest({'$**': 1}, null, ['a', 'b.c', 'b.d.e', 'b.f']);
// Test a $** index on a single subtree.
- runAllPathsIndexTest({'a.$**': 1}, null, ['a']);
- runAllPathsIndexTest({'b.$**': 1}, null, ['b.c', 'b.d.e', 'b.f']);
- runAllPathsIndexTest({'b.d.$**': 1}, null, ['b.d.e']);
+ runWildcardIndexTest({'a.$**': 1}, null, ['a']);
+ runWildcardIndexTest({'b.$**': 1}, null, ['b.c', 'b.d.e', 'b.f']);
+ runWildcardIndexTest({'b.d.$**': 1}, null, ['b.d.e']);
// Test a $** index which includes a subset of paths.
- runAllPathsIndexTest({'$**': 1}, {a: 1}, ['a']);
- runAllPathsIndexTest({'$**': 1}, {b: 1}, ['b.c', 'b.d.e', 'b.f']);
- runAllPathsIndexTest({'$**': 1}, {'b.d': 1}, ['b.d.e']);
- runAllPathsIndexTest({'$**': 1}, {a: 1, 'b.d': 1}, ['a', 'b.d.e']);
+ runWildcardIndexTest({'$**': 1}, {a: 1}, ['a']);
+ runWildcardIndexTest({'$**': 1}, {b: 1}, ['b.c', 'b.d.e', 'b.f']);
+ runWildcardIndexTest({'$**': 1}, {'b.d': 1}, ['b.d.e']);
+ runWildcardIndexTest({'$**': 1}, {a: 1, 'b.d': 1}, ['a', 'b.d.e']);
// Test a $** index which excludes a subset of paths.
- runAllPathsIndexTest({'$**': 1}, {a: 0}, ['b.c', 'b.d.e', 'b.f']);
- runAllPathsIndexTest({'$**': 1}, {b: 0}, ['a']);
- runAllPathsIndexTest({'$**': 1}, {'b.d': 0}, ['a', 'b.c', 'b.f']);
- runAllPathsIndexTest({'$**': 1}, {a: 0, 'b.d': 0}, ['b.c', 'b.f']);
+ runWildcardIndexTest({'$**': 1}, {a: 0}, ['b.c', 'b.d.e', 'b.f']);
+ runWildcardIndexTest({'$**': 1}, {b: 0}, ['a']);
+ runWildcardIndexTest({'$**': 1}, {'b.d': 0}, ['a', 'b.c', 'b.f']);
+ runWildcardIndexTest({'$**': 1}, {a: 0, 'b.d': 0}, ['b.c', 'b.f']);
} finally {
// Disable $** indexes once the tests have either completed or failed.
assert.commandWorked(
diff --git a/jstests/noPassthroughWithMongod/all_paths_cached_plans.js b/jstests/noPassthroughWithMongod/wildcard_index_cached_plans.js
index bd54cba889f..dea4b0733d1 100644
--- a/jstests/noPassthroughWithMongod/all_paths_cached_plans.js
+++ b/jstests/noPassthroughWithMongod/wildcard_index_cached_plans.js
@@ -1,5 +1,5 @@
/**
- * Test that cached plans which use allPaths indexes work.
+ * Test that cached plans which use wildcard indexes work.
* TODO: SERVER-36198: Move this test back to jstests/core/
*/
(function() {
@@ -10,7 +10,7 @@
assert.commandWorked(
db.adminCommand({setParameter: 1, internalQueryAllowAllPathsIndexes: true}));
- const coll = db.all_paths_cached_plans;
+ const coll = db.wildcard_cached_plans;
coll.drop();
assert.commandWorked(coll.createIndex({"b.$**": 1}));
assert.commandWorked(coll.createIndex({"a": 1}));
@@ -83,7 +83,7 @@
// Check that indexability discriminators work with collations.
(function() {
- // Create allPaths index with a collation.
+ // Create wildcard index with a collation.
assert.eq(coll.drop(), true);
assert.commandWorked(
db.createCollection(coll.getName(), {collation: {locale: "en_US", strength: 1}}));
@@ -110,7 +110,7 @@
queryWithStringExplain.queryPlanner.queryHash);
})();
- // Check that indexability discriminators work with partial allPaths indexes.
+ // Check that indexability discriminators work with partial wildcard indexes.
(function() {
assert.eq(coll.drop(), true);
assert.commandWorked(db.createCollection(coll.getName()));
diff --git a/jstests/noPassthroughWithMongod/all_paths_collation.js b/jstests/noPassthroughWithMongod/wildcard_index_collation.js
index d0fc07d3d97..92addd75de6 100644
--- a/jstests/noPassthroughWithMongod/all_paths_collation.js
+++ b/jstests/noPassthroughWithMongod/wildcard_index_collation.js
@@ -13,7 +13,7 @@
const assertArrayEq = (l, r) => assert(arrayEq(l, r));
- const coll = db.all_paths_collation;
+ const coll = db.wildcard_collation;
coll.drop();
// Extracts the winning plan for the given query and projection from the explain output.
@@ -22,7 +22,7 @@
// Runs the given query and confirms that: (1) the $** was used to answer the query, (2) the
// results produced by the $** index match the given 'expectedResults', and (3) the same output
// is produced by a COLLSCAN with the same collation.
- function assertAllPathsIndexAnswersQuery(query, expectedResults, projection) {
+ function assertWildcardIndexAnswersQuery(query, expectedResults, projection) {
// Verify that the $** index can answer this query.
const ixScans = getPlanStages(winningPlan(query, (projection || {_id: 0})), "IXSCAN");
assert.gt(ixScans.length, 0, tojson(coll.find(query).explain()));
@@ -30,9 +30,9 @@
// Assert that the $** index produces the expected results, and that these are the same
// as those produced by a COLLSCAN with the same collation.
- const allPathsResults = coll.find(query, (projection || {_id: 0})).toArray();
- assertArrayEq(allPathsResults, expectedResults);
- assertArrayEq(allPathsResults,
+ const wildcardResults = coll.find(query, (projection || {_id: 0})).toArray();
+ assertArrayEq(wildcardResults, expectedResults);
+ assertArrayEq(wildcardResults,
coll.find(query, (projection || {_id: 0}))
.collation({locale: "en_US", strength: 1})
.hint({$natural: 1})
@@ -82,11 +82,11 @@
// Confirm that only the document's values adhere to the case-insensitive collation. The
// field paths, which are also present in the $** index keys, are evaluated using simple
// binary comparison; so for instance, path "a.b" does *not* match path "A.B".
- assertAllPathsIndexAnswersQuery({"a.b": "string"}, [
+ assertWildcardIndexAnswersQuery({"a.b": "string"}, [
{a: {b: "string", c: "STRING"}, d: "sTrInG", e: 5},
{a: {b: "STRING", c: "string"}, d: "StRiNg", e: 5}
]);
- assertAllPathsIndexAnswersQuery({"A.B": "string"}, [
+ assertWildcardIndexAnswersQuery({"A.B": "string"}, [
{A: {B: "string", C: "STRING"}, d: "sTrInG", E: 5},
{A: {B: "STRING", C: "string"}, d: "StRiNg", E: 5}
]);
@@ -94,16 +94,16 @@
// All documents in the collection are returned if we query over both upper- and lower-case
// fieldnames, or when the fieldname has a consistent case across all documents.
const allDocs = coll.find({}, {_id: 0}).toArray();
- assertAllPathsIndexAnswersQuery({$or: [{"a.c": "string"}, {"A.C": "string"}]}, allDocs);
- assertAllPathsIndexAnswersQuery({d: "string"}, allDocs);
+ assertWildcardIndexAnswersQuery({$or: [{"a.c": "string"}, {"A.C": "string"}]}, allDocs);
+ assertWildcardIndexAnswersQuery({d: "string"}, allDocs);
// Confirm that the $** index also differentiates between upper and lower fieldname case
// when querying fields which do not contain string values.
- assertAllPathsIndexAnswersQuery({e: 5}, [
+ assertWildcardIndexAnswersQuery({e: 5}, [
{a: {b: "string", c: "STRING"}, d: "sTrInG", e: 5},
{a: {b: "STRING", c: "string"}, d: "StRiNg", e: 5}
]);
- assertAllPathsIndexAnswersQuery({E: 5}, [
+ assertWildcardIndexAnswersQuery({E: 5}, [
{A: {B: "string", C: "STRING"}, d: "sTrInG", E: 5},
{A: {B: "STRING", C: "string"}, d: "StRiNg", E: 5}
]);
@@ -120,7 +120,7 @@
// Confirm that attempting to project the virtual $_path field which is present in $** index
// keys produces a non-covered solution, which nonetheless returns the correct results.
assert(!isIndexOnly(coll.getDB(), winningPlan({e: 5}, {_id: 0, e: 1, $_path: 1})));
- assertAllPathsIndexAnswersQuery({e: 5}, [{e: 5}, {e: 5}], {_id: 0, e: 1, $_path: 1});
+ assertWildcardIndexAnswersQuery({e: 5}, [{e: 5}, {e: 5}], {_id: 0, e: 1, $_path: 1});
} finally {
// Disable $** indexes once the tests have either completed or failed.
db.adminCommand({setParameter: 1, internalQueryAllowAllPathsIndexes: false});
diff --git a/jstests/noPassthroughWithMongod/all_paths_covered_queries.js b/jstests/noPassthroughWithMongod/wildcard_index_covered_queries.js
index 1855ab33fdb..ecb182d45af 100644
--- a/jstests/noPassthroughWithMongod/all_paths_covered_queries.js
+++ b/jstests/noPassthroughWithMongod/wildcard_index_covered_queries.js
@@ -16,14 +16,14 @@
const assertArrayEq = (l, r) => assert(arrayEq(l, r));
- const coll = db.all_paths_covered_query;
+ const coll = db.wildcard_covered_query;
coll.drop();
// Confirms that the $** index can answer the given query and projection, that it produces a
// covered solution, and that the results are identical to those obtained by a COLLSCAN. If
// 'shouldFailToCover' is true, inverts the assertion and confirms that the given query and
// projection do *not* produce a covered plan.
- function assertAllPathsProvidesCoveredSolution(query, proj, shouldFailToCover = false) {
+ function assertWildcardProvidesCoveredSolution(query, proj, shouldFailToCover = false) {
// Obtain the explain output for the given query and projection. We run the explain with
// 'executionStats' so that we can subsequently validate the number of documents examined.
const explainOut = assert.commandWorked(coll.find(query, proj).explain("executionStats"));
@@ -58,34 +58,34 @@
assert.commandWorked(coll.createIndex({"$**": 1}));
// Verify that the $** index can cover an exact match on an integer value.
- assertAllPathsProvidesCoveredSolution({"a.b": 10}, {_id: 0, "a.b": 1});
+ assertWildcardProvidesCoveredSolution({"a.b": 10}, {_id: 0, "a.b": 1});
// Verify that the $** index can cover an exact match on a string value.
- assertAllPathsProvidesCoveredSolution({"a.c": "10"}, {_id: 0, "a.c": 1});
+ assertWildcardProvidesCoveredSolution({"a.c": "10"}, {_id: 0, "a.c": 1});
// Verify that the $** index can cover a range query for integer values.
- assertAllPathsProvidesCoveredSolution({"a.b": {$gt: 10, $lt: 99}}, {_id: 0, "a.b": 1});
+ assertWildcardProvidesCoveredSolution({"a.b": {$gt: 10, $lt: 99}}, {_id: 0, "a.b": 1});
// Verify that the $** index can cover a range query for string values.
- assertAllPathsProvidesCoveredSolution({"a.c": {$gt: "10", $lt: "99"}}, {_id: 0, "a.c": 1});
+ assertWildcardProvidesCoveredSolution({"a.c": {$gt: "10", $lt: "99"}}, {_id: 0, "a.c": 1});
// Verify that the $** index can cover an $in query for integer values.
- assertAllPathsProvidesCoveredSolution({"a.b": {$in: [0, 50, 100, 150]}},
+ assertWildcardProvidesCoveredSolution({"a.b": {$in: [0, 50, 100, 150]}},
{_id: 0, "a.b": 1});
// Verify that the $** index can cover an $in query for string values.
- assertAllPathsProvidesCoveredSolution({"a.c": {$in: ["0", "50", "100", "150"]}},
+ assertWildcardProvidesCoveredSolution({"a.c": {$in: ["0", "50", "100", "150"]}},
{_id: 0, "a.c": 1});
// Verify that attempting to project the virtual $_path field from the $** keyPattern will
// fail to do so and will instead produce a non-covered query. However, this query will
// nonetheless output the correct results.
const shouldFailToCover = true;
- assertAllPathsProvidesCoveredSolution(
+ assertWildcardProvidesCoveredSolution(
{d: {$in: [0, 25, 50, 75, 100]}}, {_id: 0, d: 1, $_path: 1}, shouldFailToCover);
// Verify that predicates which produce inexact-fetch bounds are not covered by a $** index.
- assertAllPathsProvidesCoveredSolution(
+ assertWildcardProvidesCoveredSolution(
{d: {$elemMatch: {$eq: 50}}}, {_id: 0, d: 1}, shouldFailToCover);
} finally {
// Disable $** indexes once the tests have either completed or failed.
diff --git a/jstests/noPassthroughWithMongod/all_paths_hint.js b/jstests/noPassthroughWithMongod/wildcard_index_hint.js
index 052848c636e..f4a8d8fb878 100644
--- a/jstests/noPassthroughWithMongod/all_paths_hint.js
+++ b/jstests/noPassthroughWithMongod/wildcard_index_hint.js
@@ -8,7 +8,7 @@
load("jstests/aggregation/extras/utils.js"); // For arrayEq.
load("jstests/libs/analyze_plan.js"); // For getPlanStages.
- const coll = db.all_paths_hint;
+ const coll = db.wildcard_hint;
coll.drop();
const assertArrayEq = (l, r) => assert(arrayEq(l, r), tojson(l) + " != " + tojson(r));
@@ -26,8 +26,8 @@
assert.gt(ixScans.length, 0, tojson(coll.find(query).hint(hint).explain()));
ixScans.forEach((ixScan) => assert.eq(ixScan.indexName, expectedIndexName));
- const allPathsResults = coll.find(query, {_id: 0}).hint(hint).toArray();
- assertArrayEq(allPathsResults, expectedResults);
+ const wildcardResults = coll.find(query, {_id: 0}).hint(hint).toArray();
+ assertArrayEq(wildcardResults, expectedResults);
}
assert.commandWorked(
@@ -83,7 +83,7 @@
"$**_1",
[{a: 1, b: 1, c: {d: 1, e: 1}}, {a: 2, b: 2, c: {d: 1, e: 2}}]);
- // Adding another all paths index with a path specified.
+ // Adding another wildcard index with a path specified.
assert.commandWorked(coll.createIndex({"c.$**": 1}));
// Hint on path that is not in query argument.
@@ -117,8 +117,5 @@
} finally {
// Disable $** indexes once the tests have either completed or failed.
db.adminCommand({setParameter: 1, internalQueryAllowAllPathsIndexes: false});
-
- // TODO: SERVER-36444 remove calls to drop() once wildcard index validation works.
- coll.drop();
}
})(); \ No newline at end of file
diff --git a/jstests/noPassthroughWithMongod/all_paths_index_multikey.js b/jstests/noPassthroughWithMongod/wildcard_index_multikey.js
index 375bc704ef4..7c5e7c93fea 100644
--- a/jstests/noPassthroughWithMongod/all_paths_index_multikey.js
+++ b/jstests/noPassthroughWithMongod/wildcard_index_multikey.js
@@ -11,7 +11,7 @@
const assertArrayEq = (l, r) => assert(arrayEq(l, r), tojson(l) + " != " + tojson(r));
- const coll = db.all_paths_multikey_index;
+ const coll = db.wildcard_multikey_index;
coll.drop();
// Template document which defines the 'schema' of the documents in the test collection.
@@ -60,7 +60,7 @@
// field in turn. The 'expectedPaths' argument lists the set of paths which we expect to have
// been indexed based on the spec; this function will confirm that only the appropriate paths
// are present in the $** index.
- function runAllPathsIndexTest(keyPattern, pathProjection, expectedPaths) {
+ function runWildcardIndexTest(keyPattern, pathProjection, expectedPaths) {
assert.commandWorked(coll.dropIndexes());
assert.commandWorked(coll.createIndex(
keyPattern, pathProjection ? {wildcardProjection: pathProjection} : {}));
@@ -69,16 +69,16 @@
for (let op of operationList) {
for (let path of pathList) {
const query = {[path]: op.expression};
- assertAllPathsQuery(query, expectedPaths.includes(path) ? path : null);
+ assertWildcardQuery(query, expectedPaths.includes(path) ? path : null);
}
}
}
- // Runs a single allPaths query test. If 'expectedPath' is non-null, verifies that there is an
+ // Runs a single wildcard query test. If 'expectedPath' is non-null, verifies that there is an
// indexed solution that uses the $** index with the given path string. If 'expectedPath' is
// null, verifies that no indexed solution was found. If 'explainStats' is non-empty, verifies
// that the query's explain output reflects the given stats.
- function assertAllPathsQuery(query, expectedPath, explainStats = {}) {
+ function assertWildcardQuery(query, expectedPath, explainStats = {}) {
// Explain the query, and determine whether an indexed solution is available.
const explainOutput = coll.find(query).explain("executionStats");
const ixScans = getPlanStages(explainOutput.queryPlanner.winningPlan, "IXSCAN");
@@ -106,22 +106,22 @@
db.adminCommand({setParameter: 1, internalQueryAllowAllPathsIndexes: true}));
try {
// Test a $** index that indexes the entire document.
- runAllPathsIndexTest({'$**': 1}, null, ['a', 'b.c', 'b.d.e']);
+ runWildcardIndexTest({'$**': 1}, null, ['a', 'b.c', 'b.d.e']);
// Test a $** index on a single subtree.
- runAllPathsIndexTest({'a.$**': 1}, null, ['a']);
- runAllPathsIndexTest({'b.$**': 1}, null, ['b.c', 'b.d.e']);
- runAllPathsIndexTest({'b.c.$**': 1}, null, ['b.c']);
- runAllPathsIndexTest({'b.d.$**': 1}, null, ['b.d.e']);
+ runWildcardIndexTest({'a.$**': 1}, null, ['a']);
+ runWildcardIndexTest({'b.$**': 1}, null, ['b.c', 'b.d.e']);
+ runWildcardIndexTest({'b.c.$**': 1}, null, ['b.c']);
+ runWildcardIndexTest({'b.d.$**': 1}, null, ['b.d.e']);
// Test a $** index which includes a subset of paths.
- runAllPathsIndexTest({'$**': 1}, {a: 1}, ['a']);
- runAllPathsIndexTest({'$**': 1}, {b: 1}, ['b.c', 'b.d.e']);
- runAllPathsIndexTest({'$**': 1}, {'b.d': 1}, ['b.d.e']);
- runAllPathsIndexTest({'$**': 1}, {a: 1, 'b.d': 1}, ['a', 'b.d.e']);
+ runWildcardIndexTest({'$**': 1}, {a: 1}, ['a']);
+ runWildcardIndexTest({'$**': 1}, {b: 1}, ['b.c', 'b.d.e']);
+ runWildcardIndexTest({'$**': 1}, {'b.d': 1}, ['b.d.e']);
+ runWildcardIndexTest({'$**': 1}, {a: 1, 'b.d': 1}, ['a', 'b.d.e']);
// Test a $** index which excludes a subset of paths.
- runAllPathsIndexTest({'$**': 1}, {a: 0}, ['b.c', 'b.d.e']);
- runAllPathsIndexTest({'$**': 1}, {b: 0}, ['a']);
- runAllPathsIndexTest({'$**': 1}, {'b.c': 0}, ['a', 'b.d.e']);
- runAllPathsIndexTest({'$**': 1}, {a: 0, 'b.c': 0}, ['b.d.e']);
+ runWildcardIndexTest({'$**': 1}, {a: 0}, ['b.c', 'b.d.e']);
+ runWildcardIndexTest({'$**': 1}, {b: 0}, ['a']);
+ runWildcardIndexTest({'$**': 1}, {'b.c': 0}, ['a', 'b.d.e']);
+ runWildcardIndexTest({'$**': 1}, {a: 0, 'b.c': 0}, ['b.d.e']);
// Sanity check that a few queries which need to be planned specially in the multikey case
// return the correct results.
@@ -186,17 +186,17 @@
//
// We examine the solution's 'nReturned' versus 'totalDocsExamined' to confirm this.
// totalDocsExamined: [_id:1, _id:2, _id:3, _id:4], nReturned: [_id:2, _id:3, _id:4]
- assertAllPathsQuery({'a.0.b.1.c': 1},
+ assertWildcardQuery({'a.0.b.1.c': 1},
'a.0.b.1.c',
{'executionStats.nReturned': 3, 'executionStats.totalDocsExamined': 4});
// Test that we can query a specific field of an array whose fieldname is itself numeric.
- assertAllPathsQuery({'a.0.1.d': 1},
+ assertWildcardQuery({'a.0.1.d': 1},
'a.0.1.d',
{'executionStats.nReturned': 1, 'executionStats.totalDocsExamined': 1});
// Test that we can query a primitive value at a specific array index.
- assertAllPathsQuery({'a.0.b.1.c.2.d.3': 3},
+ assertWildcardQuery({'a.0.b.1.c.2.d.3': 3},
'a.0.b.1.c.2.d.3',
{'executionStats.nReturned': 1, 'executionStats.totalDocsExamined': 1});
@@ -204,9 +204,9 @@
assert.commandWorked(
coll.insert({_id: 6, a: [{b: [{c: [{d: [{e: [{f: [{g: [{h: [{i: [1]}]}]}]}]}]}]}]}]}));
// We can query up to a depth of 8 arrays via specific indices, but not through 9 or more.
- assertAllPathsQuery({'a.0.b.0.c.0.d.0.e.0.f.0.g.0.h.0.i': 1},
+ assertWildcardQuery({'a.0.b.0.c.0.d.0.e.0.f.0.g.0.h.0.i': 1},
'a.0.b.0.c.0.d.0.e.0.f.0.g.0.h.0.i');
- assertAllPathsQuery({'a.0.b.0.c.0.d.0.e.0.f.0.g.0.h.0.i.0': 1}, null);
+ assertWildcardQuery({'a.0.b.0.c.0.d.0.e.0.f.0.g.0.h.0.i.0': 1}, null);
// Test that fieldname-or-array-index queries do not inappropriately trim predicates; that
// is, all predicates on the field are added to a FETCH filter above the IXSCAN.
@@ -220,10 +220,10 @@
assert.commandWorked(coll.insert({_id: 5, a: [4, 5, 6], b: [7, 8, 9], c: {'0': 10}}));
assert.commandWorked(coll.insert({_id: 6, a: [5, 6, 7], b: [8, 9, 10], c: {'0': 11}}));
- assertAllPathsQuery({"a.0": {$gt: 1, $lt: 4}}, 'a.0', {'executionStats.nReturned': 2});
- assertAllPathsQuery({"a.1": {$gte: 1, $lte: 4}}, 'a.1', {'executionStats.nReturned': 4});
- assertAllPathsQuery({"b.2": {$in: [5, 9]}}, 'b.2', {'executionStats.nReturned': 1});
- assertAllPathsQuery({"c.0": {$in: [10, 11]}}, 'c.0', {'executionStats.nReturned': 2});
+ assertWildcardQuery({"a.0": {$gt: 1, $lt: 4}}, 'a.0', {'executionStats.nReturned': 2});
+ assertWildcardQuery({"a.1": {$gte: 1, $lte: 4}}, 'a.1', {'executionStats.nReturned': 4});
+ assertWildcardQuery({"b.2": {$in: [5, 9]}}, 'b.2', {'executionStats.nReturned': 1});
+ assertWildcardQuery({"c.0": {$in: [10, 11]}}, 'c.0', {'executionStats.nReturned': 2});
// Test that the $** index doesn't trim predicates when planning across multiple nested
// $and/$or expressions on various fieldname-or-array-index paths.
diff --git a/jstests/noPassthroughWithMongod/all_paths_index_nonblocking_sort.js b/jstests/noPassthroughWithMongod/wildcard_index_nonblocking_sort.js
index d27ee6b19e9..b9c7edb3921 100644
--- a/jstests/noPassthroughWithMongod/all_paths_index_nonblocking_sort.js
+++ b/jstests/noPassthroughWithMongod/wildcard_index_nonblocking_sort.js
@@ -4,7 +4,7 @@
load("jstests/aggregation/extras/utils.js"); // For arrayEq().
load("jstests/libs/analyze_plan.js"); // For getPlanStages().
- const coll = db.all_paths_nonblocking_sort;
+ const coll = db.wildcard_nonblocking_sort;
// Required in order to build $** indexes.
assert.commandWorked(
@@ -64,8 +64,4 @@
checkQueryUsesBlockingSortAndGetsCorrectResults({}, {a: 1});
checkQueryUsesBlockingSortAndGetsCorrectResults({x: 123}, {a: 1});
checkQueryUsesBlockingSortAndGetsCorrectResults({excludedField: {$gte: 0}}, {excludedField: 1});
-
- // TODO SERVER-36444: Remove drop once collection validation works with indexes that have
- // multikey entries.
- coll.drop();
})();
diff --git a/jstests/noPassthroughWithMongod/all_paths_partial_index.js b/jstests/noPassthroughWithMongod/wildcard_index_partial_index.js
index 8cd6f80c9db..4e8d8ec090f 100644
--- a/jstests/noPassthroughWithMongod/all_paths_partial_index.js
+++ b/jstests/noPassthroughWithMongod/wildcard_index_partial_index.js
@@ -8,9 +8,9 @@
load("jstests/libs/analyze_plan.js"); // For isIxScan, isCollscan.
- const coll = db.all_paths_partial_index;
+ const coll = db.wildcard_partial_index;
- function testPartialAllPathsIndex(indexKeyPattern, indexOptions) {
+ function testPartialWildcardIndex(indexKeyPattern, indexOptions) {
coll.drop();
assert.commandWorked(coll.createIndex(indexKeyPattern, indexOptions));
@@ -47,10 +47,10 @@
assert.commandWorked(
db.adminCommand({setParameter: 1, internalQueryAllowAllPathsIndexes: true}));
- testPartialAllPathsIndex({"$**": 1}, {partialFilterExpression: {a: {$lte: 1.5}}});
+ testPartialWildcardIndex({"$**": 1}, {partialFilterExpression: {a: {$lte: 1.5}}});
// Case where the partial filter expression is on a field not included in the index.
- testPartialAllPathsIndex({"x.$**": 1}, {partialFilterExpression: {a: {$lte: 1.5}}});
+ testPartialWildcardIndex({"x.$**": 1}, {partialFilterExpression: {a: {$lte: 1.5}}});
} finally {
// Disable $** indexes once the tests have either completed or failed.
db.adminCommand({setParameter: 1, internalQueryAllowAllPathsIndexes: false});
diff --git a/jstests/noPassthroughWithMongod/all_paths_return_key.js b/jstests/noPassthroughWithMongod/wildcard_index_return_key.js
index 75d503b320b..382aa9cfb98 100644
--- a/jstests/noPassthroughWithMongod/all_paths_return_key.js
+++ b/jstests/noPassthroughWithMongod/wildcard_index_return_key.js
@@ -7,7 +7,7 @@
load("jstests/aggregation/extras/utils.js");
- const coll = db.all_paths_return_key;
+ const coll = db.wildcard_return_key;
coll.drop();
const assertArrayEq = (l, r) => assert(arrayEq(l, r), tojson(l) + " != " + tojson(r));
diff --git a/jstests/noPassthroughWithMongod/all_paths_validindex.js b/jstests/noPassthroughWithMongod/wildcard_index_validindex.js
index 165b1fc6bc5..b73b21ae09f 100644
--- a/jstests/noPassthroughWithMongod/all_paths_validindex.js
+++ b/jstests/noPassthroughWithMongod/wildcard_index_validindex.js
@@ -1,5 +1,5 @@
/**
- * Tests parsing and validation of allPaths indexes.
+ * Tests parsing and validation of wildcard indexes.
* @tags: [
* # Uses index building in background
* requires_background_index,
@@ -9,10 +9,10 @@
(function() {
"use strict";
- const kCollectionName = "all_paths_validindex";
+ const kCollectionName = "wildcard_validindex";
const coll = db.getCollection(kCollectionName);
- const kIndexName = "all_paths_validindex";
+ const kIndexName = "wildcard_validindex";
const createIndexHelper = function(key, parameters) {
return db.runCommand(
@@ -33,27 +33,27 @@
assert.commandWorked(
db.adminCommand({setParameter: 1, internalQueryAllowAllPathsIndexes: true}));
try {
- // Can create a valid allPaths index.
+ // Can create a valid wildcard index.
createIndexAndVerifyWithDrop({"$**": 1}, {name: kIndexName});
- // Can create a valid allPaths index with subpaths.
+ // Can create a valid wildcard index with subpaths.
createIndexAndVerifyWithDrop({"a.$**": 1}, {name: kIndexName});
- // Can create an allPaths index with partialFilterExpression.
+ // Can create a wildcard index with partialFilterExpression.
createIndexAndVerifyWithDrop({"$**": 1},
{name: kIndexName, partialFilterExpression: {a: {"$gt": 0}}});
- // Can create an allPaths index with foreground & background construction.
+ // Can create a wildcard index with foreground & background construction.
createIndexAndVerifyWithDrop({"$**": 1}, {background: false, name: kIndexName});
createIndexAndVerifyWithDrop({"$**": 1}, {background: true, name: kIndexName});
- // Can create an allPaths index with index level collation.
+ // Can create a wildcard index with index level collation.
createIndexAndVerifyWithDrop({"$**": 1}, {collation: {locale: "fr"}, name: kIndexName});
- // Can create an allPaths index with an inclusion projection.
+ // Can create a wildcard index with an inclusion projection.
createIndexAndVerifyWithDrop({"$**": 1},
{wildcardProjection: {a: 1, b: 1, c: 1}, name: kIndexName});
- // Can create an allPaths index with an exclusion projection.
+ // Can create a wildcard index with an exclusion projection.
createIndexAndVerifyWithDrop({"$**": 1},
{wildcardProjection: {a: 0, b: 0, c: 0}, name: kIndexName});
// Can include _id in an exclusion.
@@ -63,12 +63,12 @@
createIndexAndVerifyWithDrop(
{"$**": 1}, {wildcardProjection: {_id: 0, a: 1, b: 1, c: 1}, name: kIndexName});
- // Cannot create an allPaths index with sparse option.
+ // Cannot create a wildcard index with sparse option.
coll.dropIndexes();
assert.commandFailedWithCode(coll.createIndex({"$**": 1}, {sparse: true}),
ErrorCodes.CannotCreateIndex);
- // Cannot create an allPaths index with a v0 or v1 index.
+ // Cannot create a wildcard index with a v0 or v1 index.
assert.commandFailedWithCode(coll.createIndex({"$**": 1}, {v: 0}),
ErrorCodes.CannotCreateIndex);
assert.commandFailedWithCode(coll.createIndex({"$**": 1}, {v: 1}),
@@ -78,36 +78,36 @@
assert.commandFailedWithCode(coll.createIndex({"$**": 1}, {unique: true}),
ErrorCodes.CannotCreateIndex);
- // Cannot create a hashed all paths index.
+ // Cannot create a hashed wildcard index.
assert.commandFailedWithCode(coll.createIndex({"$**": "hashed"}),
ErrorCodes.CannotCreateIndex);
- // Cannot create a TTL all paths index.
+ // Cannot create a TTL wildcard index.
assert.commandFailedWithCode(coll.createIndex({"$**": 1}, {expireAfterSeconds: 3600}),
ErrorCodes.CannotCreateIndex);
- // Cannot create a geoSpatial all paths index.
+ // Cannot create a geoSpatial wildcard index.
assert.commandFailedWithCode(coll.createIndex({"$**": "2dsphere"}),
ErrorCodes.CannotCreateIndex);
assert.commandFailedWithCode(coll.createIndex({"$**": "2d"}), ErrorCodes.CannotCreateIndex);
- // Cannot create a text all paths index using single sub-path syntax.
+ // Cannot create a text wildcard index using single sub-path syntax.
assert.commandFailedWithCode(coll.createIndex({"a.$**": "text"}),
ErrorCodes.CannotCreateIndex);
// Cannot specify plugin by string.
- assert.commandFailedWithCode(coll.createIndex({"a": "allPaths"}),
+ assert.commandFailedWithCode(coll.createIndex({"a": "wildcard"}),
ErrorCodes.CannotCreateIndex);
- assert.commandFailedWithCode(coll.createIndex({"$**": "allPaths"}),
+ assert.commandFailedWithCode(coll.createIndex({"$**": "wildcard"}),
ErrorCodes.CannotCreateIndex);
- // Cannot create a compound all paths index.
+ // Cannot create a compound wildcard index.
assert.commandFailedWithCode(coll.createIndex({"$**": 1, "a": 1}),
ErrorCodes.CannotCreateIndex);
assert.commandFailedWithCode(coll.createIndex({"a": 1, "$**": 1}),
ErrorCodes.CannotCreateIndex);
- // Cannot create an all paths index with an invalid spec.
+ // Cannot create an wildcard index with an invalid spec.
assert.commandFailedWithCode(coll.createIndex({"a.$**.$**": 1}),
ErrorCodes.CannotCreateIndex);
assert.commandFailedWithCode(coll.createIndex({"$**.$**": 1}),
@@ -115,16 +115,16 @@
assert.commandFailedWithCode(coll.createIndex({"$**": "hello"}),
ErrorCodes.CannotCreateIndex);
- // Cannot create an all paths index with mixed inclusion exclusion.
+ // Cannot create an wildcard index with mixed inclusion exclusion.
assert.commandFailedWithCode(
createIndexHelper({"$**": 1}, {name: kIndexName, wildcardProjection: {a: 1, b: 0}}),
40178);
- // Cannot create an all paths index with computed fields.
+ // Cannot create an wildcard index with computed fields.
assert.commandFailedWithCode(
createIndexHelper({"$**": 1},
{name: kIndexName, wildcardProjection: {a: 1, b: "string"}}),
ErrorCodes.FailedToParse);
- // Cannot create an all paths index with an empty projection.
+ // Cannot create an wildcard index with an empty projection.
assert.commandFailedWithCode(
createIndexHelper({"$**": 1}, {name: kIndexName, wildcardProjection: {}}),
ErrorCodes.FailedToParse);
@@ -137,7 +137,7 @@
createIndexHelper({"$**": "text"},
{name: kIndexName, wildcardProjection: {a: 1, b: 1}}),
ErrorCodes.BadValue);
- // Cannot create an all paths index with a non-object "wildcardProjection" projection.
+ // Cannot create an wildcard index with a non-object "wildcardProjection" projection.
assert.commandFailedWithCode(
createIndexHelper({"a.$**": 1}, {name: kIndexName, wildcardProjection: "string"}),
ErrorCodes.TypeMismatch);