This change involves unifying the behavior of find and
agg for validation of $meta:"textScore". In particular, find
operations no longer require a "textScore" $meta projection
in order to specify a "textScore" $meta sort. This brings
find into alignment with agg, which never had such a
restriction. It is also now legal for a find command to
sort on the field overridden by a $meta:"textScore" projection
without specifying the $meta operator in the sort pattern.
In addition:
- Tightens validation around uses of "textScore" $meta
projections for queries that do not specify a $text
predicate.
- Fixes a bug in which $natural sort/hint were not
correctly validated.
This change results in the multi-planning mechanism
evaluating both non-blocking and blocking plans for the
$sort when possible. The system should no longer select a
non-blocking plan when a plan with a SORT stage is superior.
In addition towards working towards the general goal of
doing as much query execution as possible with a PlanStage
tree, this should have a positive performance impact for
certain agg pipelines. Previously, a pipeline with a
$project (or a $project-like stage such as $addFields)
followed by a $limit might have applied this limit only
after a full batch of data was loaded by
DocumentSourceCursor. After this change, the limit will take
effect prior to DocumentSourceCursor batching, and thus may
reduce the amount of data processed by the query.