jstests/core/wildcard_index_covered_queries.js
// projection do *not* produce a covered plan.
projection do *not* produce a covered plan.
projection do * not * produce a covered plan .
function assertWildcardProvidesCoveredSolution(query, proj, shouldFailToCover = false) {
    const explainOut = assert.commandWorked(coll.find(query, proj).explain("executionStats"));
    const winningPlan = getWinningPlan(explainOut.queryPlanner);
    const ixScans = getPlanStages(winningPlan, "IXSCAN");
    assert.gt(ixScans.length, 0, tojson(explainOut));
    ixScans.forEach((ixScan) => assert(ixScan.keyPattern.hasOwnProperty("$_path")));
    assert.eq(!!explainOut.executionStats.totalDocsExamined, shouldFailToCover);
    assert.eq(isIndexOnly(coll.getDB(), winningPlan), !shouldFailToCover);
    assertArrayEq(coll.find(query, proj).toArray(),
                  coll.find(query, proj).hint({$natural: 1}).toArray());
}
function assertWildcardProvidesCoveredSolution ( query , proj , shouldFailToCover = false ) { const explainOut = assert . commandWorked ( coll . find ( query , proj ) . explain ( "executionStats" ) ) ; const winningPlan = getWinningPlan ( explainOut . queryPlanner ) ; const ixScans = getPlanStages ( winningPlan , "IXSCAN" ) ; assert . gt ( ixScans . length , 0 , tojson ( explainOut ) ) ; ixScans . forEach ( ( ixScan ) => assert ( ixScan . keyPattern . hasOwnProperty ( "$_path" ) ) ) ; assert . eq ( ! ! explainOut . executionStats . totalDocsExamined , shouldFailToCover ) ; assert . eq ( isIndexOnly ( coll . getDB ( ) , winningPlan ) , ! shouldFailToCover ) ; assertArrayEq ( coll . find ( query , proj ) . toArray ( ) , coll . find ( query , proj ) . hint ( { $natural : 1 } ) . toArray ( ) ) ; }
projection do *not* produce a covered plan.
projection do * not * produce a covered plan .
// 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. // Verify that the $** index provided the winning solution for this query. // Verify that the solution is covered, and that no documents were examined. If the argument // 'shouldFailToCover' is true, invert the validation to confirm that it is NOT covered. // Verify that the query covered by the $** index produces the same results as a COLLSCAN.