-
Notifications
You must be signed in to change notification settings - Fork 741
allow to return relevance value as a result #31285
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
allow to return relevance value as a result #31285
Conversation
|
🟢 |
|
⚪ ⚪ DetailsYa make output | Test bloat | Test bloat
⚪ Ya make output | Test bloat | Test bloat | Test bloat
🟢
*please be aware that the difference is based on comparing your commit and the last completed build from the post-commit, check comparation |
|
⚪
🟢
*please be aware that the difference is based on comparing your commit and the last completed build from the post-commit, check comparation |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR enables returning relevance values as results from full-text search queries. Previously, relevance could only be used internally for sorting; now it can be included in the SELECT clause and returned to users.
Key changes:
- Uncommented and updated test code to verify relevance values can be retrieved in query results
- Refactored full-text search optimization logic by extracting common functionality into reusable helper functions (
FindMatchingApplyandExtractFullTextSearchParams) - Extended
KqpRewriteFlatMapOverFullTextContainsto handle bothFullText.ContainsandFullText.Relevanceoperations
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| ydb/core/kqp/ut/indexes/kqp_indexes_fulltext_ut.cpp | Uncommented test code that verifies relevance values can be selected and retrieved from full-text search results, added relevance value extraction and updated debug output |
| ydb/core/kqp/opt/logical/kqp_opt_log_indexes.cpp | Refactored full-text search query optimization by extracting common logic into helper functions, added support for returning relevance values in FlatMap operations, and simplified lambda construction logic |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| TMaybeNode<TCoApply> FindMatchingApply(const TExprBase& node) { | ||
| TMaybeNode<TCoApply> matchingApply; | ||
|
|
||
| VisitExpr(node.Ptr(), [&] (const TExprNode::TPtr& expr) { | ||
| if (TCoApply::Match(expr.Get())) { | ||
| auto apply = TExprBase(expr).Cast<TCoApply>(); | ||
| if (!apply.Callable().Maybe<TCoUdf>()) { | ||
| return true; | ||
| } | ||
|
|
||
| if (apply.Args().Count() != 3) { | ||
| return true; | ||
| } | ||
|
|
||
| auto udf = apply.Callable().Maybe<TCoUdf>().Cast(); | ||
|
|
||
| if (IsIn({"FullText.Contains", "FullText.Relevance"}, udf.MethodName().Value())) { | ||
| matchingApply = apply; | ||
| return true; | ||
| } | ||
|
|
||
| } | ||
|
|
||
| return true; | ||
| }); | ||
|
|
||
| return matchingApply; | ||
| } |
Copilot
AI
Dec 24, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The FindMatchingApply function will return the last matching apply node if multiple FullText.Contains or FullText.Relevance calls exist in the expression tree, due to the visitor overwriting matchingApply on each match. This could lead to unexpected behavior if an expression contains multiple full-text operations. Consider either: (1) stopping after finding the first match by returning false from the visitor, or (2) detecting multiple matches and reporting an error if that's not a valid use case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.
ce5d823 to
8377d84
Compare
8377d84 to
b295f0e
Compare
|
⚪ ⚪ Ya make output | Test bloat | Test bloat
🟢
*please be aware that the difference is based on comparing your commit and the last completed build from the post-commit, check comparation |
|
⚪
🟢
*please be aware that the difference is based on comparing your commit and the last completed build from the post-commit, check comparation |
Changelog entry
Changelog category
Description for reviewers
...