jstests/core/wildcard_index_multikey.js
// that the query's explain output reflects the given stats.
that the query's explain output reflects the given stats.
that the query ' s explain output reflects the given stats .
function assertWildcardQuery(query, expectedPath, explainStats = {}) {
    const explainOutput = coll.find(query).explain("executionStats");
    for (let stat in explainStats) {
        assert.eq(explainStats[stat],
                  stat.split('.').reduce((obj, i) => obj[i], explainOutput),
                  explainOutput);
    }
    if (!expectedPath) {
        assert.gt(getPlanStages(getWinningPlan(explainOutput.queryPlanner), "COLLSCAN").length, 0);
        return;
    }
    const ixScans = getPlanStages(getWinningPlan(explainOutput.queryPlanner), "IXSCAN");
    assert.eq(ixScans.length, FixtureHelpers.numberOfShardsForCollection(coll));
    assert.docEq(ixScans[0].keyPattern, {"$_path": 1, [expectedPath]: 1});
    assertArrayEq(coll.find(query).toArray(), coll.find(query).hint({$natural: 1}).toArray());
}
function assertWildcardQuery ( query , expectedPath , explainStats = { } ) { const explainOutput = coll . find ( query ) . explain ( "executionStats" ) ; for ( let stat in explainStats ) { assert . eq ( explainStats [ stat ] , stat . split ( '.' ) . reduce ( ( obj , i ) => obj [ i ] , explainOutput ) , explainOutput ) ; } if ( ! expectedPath ) { assert . gt ( getPlanStages ( getWinningPlan ( explainOutput . queryPlanner ) , "COLLSCAN" ) . length , 0 ) ; return ; } const ixScans = getPlanStages ( getWinningPlan ( explainOutput . queryPlanner ) , "IXSCAN" ) ; assert . eq ( ixScans . length , FixtureHelpers . numberOfShardsForCollection ( coll ) ) ; assert . docEq ( ixScans [ 0 ] . keyPattern , { "$_path" : 1 , [ expectedPath ] : 1 } ) ; assertArrayEq ( coll . find ( query ) . toArray ( ) , coll . find ( query ) . hint ( { $natural : 1 } ) . toArray ( ) ) ; }
that the query's explain output reflects the given stats.
that the query ' s explain output reflects the given stats .
// Explain the query, and determine whether an indexed solution is available. // Verify that the explain output reflects the given 'explainStats'. // If we expect the current path to have been excluded based on the $** keyPattern // or projection, confirm that no indexed solution was found. // Verify that the winning plan uses the $** index with the expected path. // Verify that the results obtained from the $** index are identical to a COLLSCAN.