-
Notifications
You must be signed in to change notification settings - Fork 524
Query: Adds Weighted RRF capability to LINQ #5308
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
Merged
microsoft-github-policy-service
merged 8 commits into
master
from
users/leminh/WeightedRRF
Aug 7, 2025
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
2a2db74
prototype function signatures
a1c4219
prototype function signatures
f9919be
implementation
08c3191
Merge branch 'master' into users/leminh/WeightedRRF
leminh98 ff55862
Merge branch 'master' into users/leminh/WeightedRRF
leminh98 96dfcb9
update test
b90b3b6
add missing xml
42d633d
Merge branch 'master' into users/leminh/WeightedRRF
leminh98 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
77 changes: 77 additions & 0 deletions
77
....EmulatorTests/BaselineTest/TestBaseline/LinqTranslationBaselineTests.TestWeightedRRF.xml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,77 @@ | ||
| <Results> | ||
| <Result> | ||
| <Input> | ||
| <Description><![CDATA[Standard weighted RRF calls]]></Description> | ||
| <Expression><![CDATA[query.OrderByRank(doc => RRF(new [] {doc.StringField.FullTextScore(new [] {"test1"}), doc.StringField.FullTextScore(new [] {"test1", "text2"})}, new [] {1, 2})).Select(doc => doc.Pk)]]></Expression> | ||
| </Input> | ||
| <Output> | ||
| <SqlQuery><![CDATA[ | ||
| SELECT VALUE root["Pk"] | ||
| FROM root | ||
| ORDER BY RANK RRF(FullTextScore(root["StringField"], "test1"), FullTextScore(root["StringField"], "test1", "text2"), [1, 2])]]></SqlQuery> | ||
| <Results><![CDATA[[ | ||
| "Test", | ||
| "Test" | ||
| ]]]></Results> | ||
| </Output> | ||
| </Result> | ||
| <Result> | ||
| <Input> | ||
| <Description><![CDATA[Standard weighted RRF calls using anonymous types]]></Description> | ||
| <Expression><![CDATA[query.OrderByRank(doc => RRF(new [] {doc.StringField.FullTextScore(new [] {"test1"}), doc.StringField.FullTextScore(new [] {"test1", "text2"})}, new [] {1, 2})).Select(doc => doc.Pk)]]></Expression> | ||
| </Input> | ||
| <Output> | ||
| <SqlQuery><![CDATA[ | ||
| SELECT VALUE root["Pk"] | ||
| FROM root | ||
| ORDER BY RANK RRF(FullTextScore(root["StringField"], "test1"), FullTextScore(root["StringField"], "test1", "text2"), [1, 2])]]></SqlQuery> | ||
| <Results><![CDATA[[ | ||
| "Test", | ||
| "Test" | ||
| ]]]></Results> | ||
| </Output> | ||
| </Result> | ||
| <Result> | ||
| <Input> | ||
| <Description><![CDATA[Weighted RRF with weights and functions not in a list]]></Description> | ||
| <Expression><![CDATA[query.OrderByRank(doc => RRF(new [] {doc.StringField.FullTextScore(new [] {"test1"}), doc.StringField2.FullTextScore(new [] {"test1", "test2", "test3"}), 1, 2})).Select(doc => doc.Pk)]]></Expression> | ||
| </Input> | ||
| <Output> | ||
| <SqlQuery><![CDATA[]]></SqlQuery> | ||
| <ErrorMessage><![CDATA[Expressions of type System.Double is not supported as an argument to CosmosLinqExtensions.RRF. Supported expressions are method calls to FullTextScore, VectorDistance.]]></ErrorMessage> | ||
| </Output> | ||
| </Result> | ||
| <Result> | ||
| <Input> | ||
| <Description><![CDATA[Weighted RRF with weights array first]]></Description> | ||
| <Expression><![CDATA[query.OrderByRank(doc => RRF(new [] {1, 2}, new [] {doc.StringField.FullTextScore(new [] {"test1"}), doc.StringField.FullTextScore(new [] {"test1", "text2"})})).Select(doc => doc.Pk)]]></Expression> | ||
| </Input> | ||
| <Output> | ||
| <SqlQuery><![CDATA[]]></SqlQuery> | ||
| <ErrorMessage><![CDATA[Method RRF is not supported with the given argument list.]]></ErrorMessage> | ||
| </Output> | ||
| </Result> | ||
| <Result> | ||
| <Input> | ||
| <Description><![CDATA[Weighted RRF with mixed and matched values/functions in array]]></Description> | ||
| <Expression><![CDATA[query.OrderByRank(doc => RRF(new [] {1, doc.StringField.FullTextScore(new [] {"test1"})}, new [] {2, doc.StringField.FullTextScore(new [] {"test1", "text2"})})).Select(doc => doc.Pk)]]></Expression> | ||
| </Input> | ||
| <Output> | ||
| <SqlQuery><![CDATA[]]></SqlQuery> | ||
| <ErrorMessage><![CDATA[Expressions of type System.Double is not supported as an argument to CosmosLinqExtensions.RRF. Supported expressions are method calls to FullTextScore, VectorDistance.]]></ErrorMessage> | ||
| </Output> | ||
| </Result> | ||
| <Result> | ||
| <Input> | ||
| <Description><![CDATA[Weighted RRF with mixed and matched values/functions in array 2]]></Description> | ||
| <Expression><![CDATA[query.OrderByRank(doc => RRF(new [] {doc.StringField.FullTextScore(new [] {"test1"}), doc.StringField.FullTextScore(new [] {"test1"})}, new [] {2, doc.StringField.FullTextScore(new [] {"test1", "text2"})})).Select(doc => doc.Pk)]]></Expression> | ||
| </Input> | ||
| <Output> | ||
| <SqlQuery><![CDATA[ | ||
| SELECT VALUE root["Pk"] | ||
| FROM root | ||
| ORDER BY RANK RRF(FullTextScore(root["StringField"], "test1"), FullTextScore(root["StringField"], "test1"), [2, FullTextScore(root["StringField"], "test1", "text2")])]]></SqlQuery> | ||
| <ErrorMessage><![CDATA[Status Code: BadRequest,{"errors":[{"severity":"Error","location":{"start":34,"end":200},"code":"SC2229","message":"The last parameter of the RRF function is an optional array of weights. When present, it must be a literal array of numbers, one for each of the component scores used for the RRF function. The length of this array must be the same as the number of the component scores."}]},0x800A0B00]]></ErrorMessage> | ||
| </Output> | ||
| </Result> | ||
| </Results> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.