Skip to content

Commit 9807185

Browse files
pdan101Evergreen Agent
authored andcommitted
SERVER-78160 Create new QuerySolutionNode for $search
1 parent cb15b53 commit 9807185

File tree

5 files changed

+48
-2
lines changed

5 files changed

+48
-2
lines changed

src/mongo/db/query/classic_stage_builder.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -455,7 +455,8 @@ std::unique_ptr<PlanStage> ClassicStageBuilder::build(const QuerySolutionNode* r
455455
case STAGE_SPOOL:
456456
case STAGE_SENTINEL:
457457
case STAGE_COLUMN_SCAN:
458-
case STAGE_UPDATE: {
458+
case STAGE_UPDATE:
459+
case STAGE_SEARCH: {
459460
LOGV2_WARNING(4615604, "Can't build exec tree for node", "node"_attr = *root);
460461
}
461462
}

src/mongo/db/query/query_solution.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1812,4 +1812,15 @@ void SentinelNode::appendToString(str::stream* ss, int indent) const {
18121812
addIndent(ss, indent);
18131813
*ss << "SENTINEL\n";
18141814
}
1815+
1816+
std::unique_ptr<QuerySolutionNode> SearchNode::clone() const {
1817+
return std::make_unique<SearchNode>(isSearchMeta);
1818+
}
1819+
1820+
void SearchNode::appendToString(str::stream* ss, int indent) const {
1821+
addIndent(ss, indent);
1822+
*ss << "SEARCH\n";
1823+
addIndent(ss, indent + 1);
1824+
*ss << "isSearchMeta = " << isSearchMeta << '\n';
1825+
}
18151826
} // namespace mongo

src/mongo/db/query/query_solution.h

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1660,7 +1660,6 @@ struct EqLookupNode : public QuerySolutionNode {
16601660
};
16611661

16621662
struct SentinelNode : public QuerySolutionNode {
1663-
16641663
SentinelNode() {}
16651664

16661665
virtual StageType getType() const {
@@ -1686,4 +1685,37 @@ struct SentinelNode : public QuerySolutionNode {
16861685

16871686
std::unique_ptr<QuerySolutionNode> clone() const final;
16881687
};
1688+
1689+
struct SearchNode : public QuerySolutionNode {
1690+
explicit SearchNode(bool isSearchMeta) : isSearchMeta(isSearchMeta) {}
1691+
1692+
StageType getType() const override {
1693+
return STAGE_SEARCH;
1694+
}
1695+
1696+
void appendToString(str::stream* ss, int indent) const override;
1697+
1698+
bool fetched() const {
1699+
return true;
1700+
}
1701+
1702+
FieldAvailability getFieldAvailability(const std::string& field) const {
1703+
return FieldAvailability::kFullyProvided;
1704+
}
1705+
1706+
bool sortedByDiskLoc() const override {
1707+
return false;
1708+
}
1709+
1710+
const ProvidedSortSet& providedSorts() const final {
1711+
return kEmptySet;
1712+
}
1713+
1714+
std::unique_ptr<QuerySolutionNode> clone() const final;
1715+
1716+
/**
1717+
* True for $searchMeta, False for $search query.
1718+
*/
1719+
bool isSearchMeta;
1720+
};
16891721
} // namespace mongo

src/mongo/db/query/stage_types.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ StringData stageTypeToString(StageType stageType) {
6767
{STAGE_RECORD_STORE_FAST_COUNT, "RECORD_STORE_FAST_COUNT"_sd},
6868
{STAGE_RETURN_KEY, "RETURN_KEY"_sd},
6969
{STAGE_SAMPLE_FROM_TIMESERIES_BUCKET, "SAMPLE_FROM_TIMESERIES_BUCKET"_sd},
70+
{STAGE_SEARCH, "SEARCH"_sd},
7071
{STAGE_SHARDING_FILTER, "SHARDING_FILTER"_sd},
7172
{STAGE_SKIP, "SKIP"_sd},
7273
{STAGE_SORT_DEFAULT, "SORT"_sd},

src/mongo/db/query/stage_types.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@ enum StageType {
138138
// Stages for DocumentSources.
139139
STAGE_GROUP,
140140
STAGE_EQ_LOOKUP,
141+
STAGE_SEARCH,
141142
STAGE_SENTINEL,
142143
};
143144

0 commit comments

Comments
 (0)