import {configureFailPoint} from "jstests/libs/fail_point_util.js";
const collectionName = 'test_bf_34317';
const coll = db[collectionName];
coll.drop();
const docs = [
{
_id: 108,
"str": "foreground deliverables",
},
];
const options = {
collation: {
locale: 'ru',
strength: 1,
},
};
coll.insertMany(docs);
coll.createIndex({"str": "hashed"}, options);
const pipeline = [
{$limit: 20},
{$lookup: {from: collectionName, localField: "str", foreignField: "str", as: "array"}}
];
function run(coll, pipeline, options) {
const explain = coll.explain(true).aggregate(pipeline, options);
jsTest.log(tojson(explain));
const result = coll.aggregate(pipeline, options).toArray();
jsTest.log(tojson(result));
}
jsTest.log('Run with enabled optimization');
run(coll, pipeline, options);
jsTest.log('Run with disabled optimization');
configureFailPoint(db, 'disableMatchExpressionOptimization');
configureFailPoint(db, 'disablePipelineOptimization');
run(coll, pipeline, options);