SERVER-119552: Fix view resolution check for extensions (#48269)
GitOrigin-RevId: 430700e8c31fb7e6ef88a46f25982be0cf731315
This commit is contained in:
parent
a4298e2cd1
commit
54a1582c93
@ -61,6 +61,32 @@ inline bool hasMongotExtension(const auto& extensionNames) {
|
||||
|
||||
} // namespace detail
|
||||
|
||||
/**
|
||||
* Checks that the pipeline isn't empty and if the first stage in the pipeline is the $vectorSearch
|
||||
* extension stage. The legacy stage returns false.
|
||||
*
|
||||
* TODO SERVER-117168 Remove this function.
|
||||
*/
|
||||
inline bool isExtensionVectorSearchPipeline(
|
||||
const std::shared_ptr<IncrementalFeatureRolloutContext>& ifrContext,
|
||||
const std::vector<BSONObj>& pipeline) {
|
||||
if (pipeline.empty()) {
|
||||
return false;
|
||||
}
|
||||
const auto& firstStageBson = pipeline[0];
|
||||
using detail::is;
|
||||
if (is<DocumentSourceVectorSearch>(firstStageBson)) {
|
||||
// Note we don't need to worry about/consult 'featureFlagExtensionViewsAndUnionWith'
|
||||
// because the extension will enforce this behavior by toggling
|
||||
// 'gFeatureFlagVectorSearchExtension' and retrying, so thankfully this is enough, and
|
||||
// we don't need to understand what context this BSON appears in (w.r.t. views or
|
||||
// sub-pipelines).
|
||||
return ifrContext->getSavedFlagValue(feature_flags::gFeatureFlagVectorSearchExtension) &&
|
||||
detail::hasMongotExtension(serverGlobalParams.extensions);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks that the pipeline isn't empty and if the first stage in the pipeline is a mongot stage
|
||||
* Namely, that includes:
|
||||
|
||||
@ -71,7 +71,8 @@ std::vector<BSONObj> buildResolvedPipelineForSimpleCase(
|
||||
// Mongot user pipelines are a unique case: $_internalSearchIdLookup applies the view pipeline.
|
||||
// For this reason, we do not expand the aggregation request to include the view pipeline.
|
||||
// Caller is expected to use LiteParsedPipeline::handleView() for such cases.
|
||||
if (search_helper_bson_obj::isMongotPipeline(ifrContext, userPipeline)) {
|
||||
if (search_helper_bson_obj::isMongotPipeline(ifrContext, userPipeline) ||
|
||||
search_helper_bson_obj::isExtensionVectorSearchPipeline(ifrContext, userPipeline)) {
|
||||
return userPipeline;
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user