Skip to content

Query: Adds an environment variable for disabling the hybrid search query plan optimization#5120

Merged
microsoft-github-policy-service[bot] merged 4 commits intomasterfrom
users/ndeshpan/ftsQueryPlanOptSwitch
Apr 11, 2025
Merged

Query: Adds an environment variable for disabling the hybrid search query plan optimization#5120
microsoft-github-policy-service[bot] merged 4 commits intomasterfrom
users/ndeshpan/ftsQueryPlanOptSwitch

Conversation

@neildsh
Copy link
Copy Markdown
Contributor

@neildsh neildsh commented Apr 10, 2025

Description

This change adds a configuration whose value will be read from the environment variable AZURE_COSMOS_HYBRID_SEARCH_QUERYPLAN_OPTIMIZATION_DISABLED. If this evaluates to true, then the optimization for skipping the order by rewrite for hybrid search is disabled.

The environment variable is read, and the value is propagated as an internally visible query request option. This is plumbed down in the query plan APIs where it is either used to populate the supported query features header in case of a gateway or it is used as a flag passed into ServiceInterop.

Type of change

  • New feature (non-breaking change which adds functionality)

@neildsh neildsh force-pushed the users/ndeshpan/ftsQueryPlanOptSwitch branch from 2dacf1e to 534f66d Compare April 11, 2025 21:01
Comment thread Microsoft.Azure.Cosmos/src/Util/ConfigurationManager.cs
adityasa
adityasa previously approved these changes Apr 11, 2025
Copy link
Copy Markdown
Contributor

@adityasa adityasa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:shipit:

@neildsh neildsh added the QUERY label Apr 11, 2025
@neildsh neildsh added the auto-merge Enables automation to merge PRs label Apr 11, 2025
@microsoft-github-policy-service microsoft-github-policy-service Bot enabled auto-merge (squash) April 11, 2025 22:30
Copy link
Copy Markdown
Contributor

@adityasa adityasa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:shipit:

@microsoft-github-policy-service microsoft-github-policy-service Bot merged commit 65000b5 into master Apr 11, 2025
27 checks passed
@microsoft-github-policy-service microsoft-github-policy-service Bot deleted the users/ndeshpan/ftsQueryPlanOptSwitch branch April 11, 2025 23:40
microsoft-github-policy-service Bot pushed a commit that referenced this pull request May 6, 2025
…h to be disabled (#5171)

## Description
#5120 enabled the switch to ask for the optimized query plan by default.
However, the pipeline support for the optimized query plan is in #5121.
This will lead to exceptions in the hybrid search query pipeline in
version 3.49.0 if the SDK talks to a newer gateway that can return the
optimized query plan. To prevent this, we change this optimization to be
disabled by default.

## Type of change

- [x] Bug fix (non-breaking change which fixes an issue)

Co-authored-by: Debdatta Kunda <87335885+kundadebdatta@users.noreply.github.com>
neildsh added a commit that referenced this pull request May 6, 2025
…h to be disabled (#5171)

## Description
#5120 enabled the switch to ask for the optimized query plan by default.
However, the pipeline support for the optimized query plan is in #5121.
This will lead to exceptions in the hybrid search query pipeline in
version 3.49.0 if the SDK talks to a newer gateway that can return the
optimized query plan. To prevent this, we change this optimization to be
disabled by default.

## Type of change

- [x] Bug fix (non-breaking change which fixes an issue)

Co-authored-by: Debdatta Kunda <87335885+kundadebdatta@users.noreply.github.com>
microsoft-github-policy-service Bot pushed a commit that referenced this pull request May 6, 2025
…h to be disabled (#5174)

This is a cherry-pick of #5171 

## Description
#5120 enabled the switch to ask for the optimized query plan by default.
However, the pipeline support for the optimized query plan is in #5121.
This will lead to exceptions in the hybrid search query pipeline in
version 3.49.0 if the SDK talks to a newer gateway that can return the
optimized query plan. To prevent this, we change this optimization to be
disabled by default.

## Type of change

- [x] Bug fix (non-breaking change which fixes an issue)

Co-authored-by: Debdatta Kunda <87335885+kundadebdatta@users.noreply.github.com>
amanrao23 added a commit to Azure/azure-sdk-for-js that referenced this pull request May 9, 2025
…34222)

### Packages impacted by this PR
@azure/cosmos

### Issues associated with this PR
#34221


### Describe the problem that is addressed by this PR

1. ***Add support for weighted RRF in hybrid search.***
We allow weights to be negative but the negative sign is used to signal
that we should sort scores in ascending order for the corresponding
component. The final WRRF score is then computed using the absolute
value of the weight.
In this approach, the sign of the weight indicates the interpretation of
the ranking itself rather than directly affecting the calculated score:
WRRF(d) = ∑ |w_i| × 1/(k + r_i'(d))

2. ***Adds support for the optimized query plan***
Adds a QueryFeature that returns optimized query plan, effectively
removing the need for rewriting orderByExpressions in the SDK.
A flag `disableHybridSearchQueryPlanOptimization` is added to disable
returning optimized query plan. This is done to ensure the query works
as expected for older gateways.

### Are there test cases added in this PR? _(If not, why?)_
Yes

### Provide a list of related PRs _(if any)_
* Azure/azure-cosmos-dotnet-v3#5064
* Azure/azure-cosmos-dotnet-v3#5120
* Azure/azure-cosmos-dotnet-v3#5121

### Command used to generate this PR:**_(Applicable only to SDK release
request PRs)_

### Checklists
- [ ] Added impacted package name to the issue description
- [ ] Does this PR needs any fixes in the SDK Generator?** _(If so,
create an Issue in the
[Autorest/typescript](https://github.com/Azure/autorest.typescript)
repository and link it here)_
- [ ] Added a changelog (if necessary)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

auto-merge Enables automation to merge PRs QUERY

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants