Files
mongo/jstests/core/fts_explain.js
Justin Seyster fc252a5574 SERVER-26833 Non-blocking text queries when projection ignores score.
With this change, text queries use the non-blocking OR stage in place
of the blocking TEXT_OR stage when it is not necessary to compute the
text score (because the projection does not call for it).

We also removed the unnecessary MatchableTextDocument object with this
change. This object was used in the TEXT_OR stage to apply a filter to
index entries. The query planner adds search predicates as a filter in
the OR/TEXT_OR stage when they can be covered by the index, allowing
them to get filtered out before the full document need be examined

However, the OR stage uses an IndexMatchableDocument which does almost
the same thing. The only difference is that TextMatchableDocument will
fetch documents if the index does not cover the filter. Since that
should never happen (if the query planner is doing its job right), we
shouldn't need TextMatchableDocument.
2017-10-19 01:31:09 -04:00

39 lines
1.3 KiB
JavaScript

// Cannot implicitly shard accessed collections because of extra shard key index in sharded
// collection.
// @tags: [assumes_no_implicit_index_creation]
// Test $text explain. SERVER-12037.
(function() {
"use strict";
const coll = db.fts_explain;
let res;
coll.drop();
res = coll.ensureIndex({content: "text"}, {default_language: "none"});
assert.commandWorked(res);
res = coll.insert({content: "some data"});
assert.writeOK(res);
const explain =
coll.find({$text: {$search: "\"a\" -b -\"c\""}}, {content: 1, score: {$meta: "textScore"}})
.explain(true);
let stage = explain.executionStats.executionStages;
if ("SINGLE_SHARD" === stage.stage) {
stage = stage.shards[0].executionStages;
}
assert.eq(stage.stage, "PROJECTION");
let textStage = stage.inputStage;
assert.eq(textStage.stage, "TEXT");
assert.gte(textStage.textIndexVersion, 1, "textIndexVersion incorrect or missing.");
assert.eq(textStage.inputStage.stage, "TEXT_MATCH");
assert.eq(textStage.inputStage.inputStage.stage, "TEXT_OR");
assert.eq(textStage.parsedTextQuery.terms, ["a"]);
assert.eq(textStage.parsedTextQuery.negatedTerms, ["b"]);
assert.eq(textStage.parsedTextQuery.phrases, ["a"]);
assert.eq(textStage.parsedTextQuery.negatedPhrases, ["c"]);
})();