From 2ff0709876f2bf2cde124fec2f1f07a1cacbd95c Mon Sep 17 00:00:00 2001 From: Arnab Nandy Date: Thu, 16 Jul 2026 03:02:00 +0530 Subject: [PATCH] Fix duplicate hybrid search result subscription Signed-off-by: Arnab Nandy --- sdk/cosmos/azure-cosmos/CHANGELOG.md | 1 + .../query/HybridSearchDocumentQueryExecutionContext.java | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/sdk/cosmos/azure-cosmos/CHANGELOG.md b/sdk/cosmos/azure-cosmos/CHANGELOG.md index 9cbcee519b89..41da6efb03a9 100644 --- a/sdk/cosmos/azure-cosmos/CHANGELOG.md +++ b/sdk/cosmos/azure-cosmos/CHANGELOG.md @@ -9,6 +9,7 @@ #### Breaking Changes #### Bugs Fixed +* Fixed an intermittent `IndexOutOfBoundsException` in cross-partition hybrid search queries caused by multiple subscriptions to the coalesced component query results. - See [Issue 49823](https://github.com/Azure/azure-sdk-for-java/issues/49823) * Unified request-level consistency override behavior across transports: invalid attempts to upgrade the request consistency level above the account default are now silently ignored instead of returning `BadRequest` in some gateway paths. - See PR [49606](https://github.com/Azure/azure-sdk-for-java/pull/49606). * Fixed `partitionLevelCircuitBreakerCfg` missing from the `clientCfgs` section of `CosmosDiagnostics` when Per-Partition Circuit Breaker is explicitly enabled. - See PR [49734](https://github.com/Azure/azure-sdk-for-java/pull/49734). * Fixed thin-client (Gateway V2) queries with a prefix (partial) hierarchical partition key returning co-located documents from other logical partitions. - See PR [49688](https://github.com/Azure/azure-sdk-for-java/pull/49688). diff --git a/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/implementation/query/HybridSearchDocumentQueryExecutionContext.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/implementation/query/HybridSearchDocumentQueryExecutionContext.java index 830a37a2dda4..b05249db89ec 100644 --- a/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/implementation/query/HybridSearchDocumentQueryExecutionContext.java +++ b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/implementation/query/HybridSearchDocumentQueryExecutionContext.java @@ -197,7 +197,8 @@ private Flux> hybridSearch(List componentQueryResults = getComponentQueryResults(targetFeedRanges, initialPageSize, collection, rewrittenQueryInfos); // Coalesce the results on unique _rids, and sort it based on the _rid - Mono>> coalescedAndSortedResults = coalesceAndSortResults(componentQueryResults); + Mono>> coalescedAndSortedResults = + coalesceAndSortResults(componentQueryResults).cache(); // Compose component scores matrix, where each tuple is (score, index) Mono>> componentScoresList = retrieveComponentScores(coalescedAndSortedResults, componentWeights);