Cosmos DB Tool icon

Cosmos DB Tool

Cosmos DB retrieval tool for AI Agent workflows

Hybrid Search

AI-generated

Summary

Perform a hybrid search combining semantic vector search and full-text keyword search on documents stored in a specified Azure Cosmos DB container.

Inputs

  • Authentication Type (required) — Method to authenticate to Cosmos DB, either with a Master Key or Microsoft Entra ID (Azure AD).
  • Database Name or ID (required) — The Cosmos DB database to query, selectable from a loaded list or dynamically set via expression.
  • Container Name or ID (required) — The container within the selected database to search, selectable from a loaded list or dynamically set via expression.
  • Keyword (Full Text Search) — Default space-separated full-text search keywords used if not provided by the tool input.
  • Search Query (Vector Search) — Default semantic vector search query used if not provided by the tool input.
  • Vector Field Name (required) — The field name in documents that stores the vector embedding for vector search.
  • Full Text Field Name (required) — The field name in documents used for full-text search scoring.
  • Top K — Maximum number of top results to retrieve from the database if not overridden by the tool input. Defaults to 10.
  • Include Debug Info — Whether to include detailed embedding, query, and result diagnostics in the output.
  • Partition Key Field — Document field used as partition key for optional filtering.
  • Partition Key Value — Optional value to filter documents by the partition key field.
  • Additional SQL Filters — Additional SQL WHERE condition filters to refine the search results (without the WHERE keyword).
  • Fields to Return — Comma-separated list of specific document fields to return instead of entire documents.
  • Simplify Output — Whether to remove common Cosmos DB metadata fields (_rid, _self, _etag, _attachments, _ts) from returned documents.
  • Exclude Fields — Whether to exclude additional specified fields from the output documents.
  • Fields to Exclude — Comma-separated list of fields to exclude when 'Exclude Fields' is enabled.
  • Use Dev Override (Custom Endpoint + Token) — Enable to override credentials with a custom Cosmos DB endpoint URL and bearer token.
  • Custom Endpoint — Custom Cosmos DB account endpoint URL, used when Dev Override is enabled.
  • Custom Access Token — Bearer token for authentication to the custom endpoint, used when Dev Override is enabled.

Output shape

a JSON string representing an array of matched documents or a JSON object with results and optional debug information

If no documents match, returns a JSON message indicating no results found. Returned documents can be filtered to exclude metadata or specific fields. The operation requires an AI Embedding model connected as input to generate vector embeddings dynamically. Optionally accepts an AI Reranker input to reorder results based on query relevance. Tool input can override default keyword, query, topK, partition filtering, and other parameters at runtime.

Examples

Example 1: Search the 'research' partition of a 'papers' container for documents semantically matching 'retrieval-augmented generation' with full-text ranking on keywords 'azure cosmos db vector search', returning top 10 results with vector field 'vector' and text field 'text'.

Authentication using Master Key; database and container selected; default keyword and search query set; vector and full-text fields specified; topK set to 10; optional debug info disabled; simplifying output enabled to remove metadata fields.

Links

Discussion