Skip to content

[Cosmos] [Embedding V0] Wire resolver into _run_hybrid_search and plumb generator through dispatcher #46733

@ananth7592

Description

@ananth7592

Wire _resolve_embeddings into _run_hybrid_search (sync + async) and plumb generator through dispatcher

Parent: 46729
Depends on: 46732

Goal

Make the new helper actually run on real queries. Also fail-fast when the gateway returns an embeddingParameterMap but no generator is configured.

Scope

  1. azure/cosmos/_execution_context/execution_dispatcher.py :: _ProxyQueryExecutionContext._create_pipelined_execution_context – pass self._options through unchanged (already happens; just confirm embeddingGenerator survives).
  2. _HybridSearchContextAggregator._run_hybrid_search:
    • After the rewrite step (where rewritten_query_infos are constructed)
    • Before the per-partition document-producer fan-out
    • call self._resolve_embeddings().
  3. Mirror in aio/hybrid_search_aggregator.py – await _resolve_embeddings_async() from the async _run_hybrid_search.
  4. Make sure the augmented self._parameters is what _attach_parameters consumes when building per-component queries.

Backward compatibility

  • If no plan field and no generator: zero behavior change.
  • If plan has the field but generator is missing: clean ValueError with a message that names the option (embedding_generator) — see 46732.
  • If generator is configured but plan doesn't ask for embeddings: no-op (helper returns early).

Files touched

  • sdk/cosmos/azure-cosmos/azure/cosmos/_execution_context/hybrid_search_aggregator.py
  • sdk/cosmos/azure-cosmos/azure/cosmos/_execution_context/aio/hybrid_search_aggregator.py
  • (Possibly) sdk/cosmos/azure-cosmos/azure/cosmos/_execution_context/execution_dispatcher.py if option propagation needs explicit hand-off.

Acceptance

  • A hybrid-search query with embedding_generator set, against a mock plan that returns one entry in embeddingParameterMap, produces per-component queries whose parameters list includes @documentdb-hybridsearchquery-embedding-0 with the mocked vector.
  • Existing hybrid-search emulator tests still pass with no embedding_generator set.
  • Sync and async paths covered.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Cosmosfeature-requestThis issue requires a new behavior in the product in order be resolved.

    Type

    No type

    Projects

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions