-
Type:
Improvement
-
Resolution: Unresolved
-
Priority:
Minor - P4
-
None
-
Affects Version/s: None
-
Component/s: None
-
Query Integration
-
None
-
None
-
None
-
None
-
None
-
None
-
None
Overview
Hybrid search ($rankFusion/$scoreFusion) validates whether an input pipeline stage is ranked/scored/selection at lite-parse time, on the pre-desugar LiteParsedExpandable (backed by an extension ParseNode). The ParseNode has no properties of its own, so LiteParsedExpandable::isRankedStage()/isScoredStage()/isSelectionStage() currently reduce over the stage's expansion (any-ranked / any-scored / all-selection over the expanded AstNodes).
Problem
This means the host infers eligibility from the expansion rather than the extension declaring it. An extension whose expansion contains stages that individually look non-selection (e.g. a $setMetadata) but whose net result is a valid hybrid-search input cannot declare itself eligible, and faking the per-AstNode properties to win the reduction would corrupt those nodes' individual semantics (which are read downstream for query shape, etc.).
Proposal
Add get_properties to MongoExtensionAggStageParseNodeVTable (mirroring the existing AggStageAstNode get_properties), with SDK + host-handle plumbing, so the extension declares the stage's net hybrid-search properties on the ParseNode. Then have LiteParsedExpandable::isRankedStage()/isScoredStage()/isSelectionStage() read the declared properties directly and delete the reduce-over-expansion overrides. This is an extension public-API addition (vtable member): bump MONGODB_EXTENSION_API_MINOR_VERSION and keep the per-expansion reduction as the fallback when an extension does not supply properties, so extensions built against the current ABI keep working.
Context
Raised in review of PR #55642 (SERVER-128285). Keeping the conservative per-expansion reduction in that PR until this lands.