Skip to content

Fix cosmosSearch vector field name: query -> vector#24

Merged
khelanmodi merged 1 commit into
Azure:mainfrom
khelanmodi:fix/cosmossearch-vector-field
May 26, 2026
Merged

Fix cosmosSearch vector field name: query -> vector#24
khelanmodi merged 1 commit into
Azure:mainfrom
khelanmodi:fix/cosmossearch-vector-field

Conversation

@khelanmodi
Copy link
Copy Markdown
Collaborator

Summary

The cosmosSearch operator in Azure DocumentDB's `` aggregation stage takes the query embedding under the vector field, not `query`. The current vector-search examples use `query:` which is invalid syntax — queries built from these examples will fail at runtime (or silently return wrong results, depending on server build).

This is high-impact because skills/vector-search/vector-knn-query.md is the canonical example the agent surfaces for any ""how do I do vector search?"" prompt, so the agent currently generates broken queries by default.

Changes

Three call sites fixed:

File Before After
skills/vector-search/vector-knn-query.md (incorrect example) query: qv vector: qv
skills/vector-search/vector-knn-query.md (correct example) query: queryVector vector: queryVector
skills/full-text-search/fts-hybrid-search.md (vector arm of hybrid) query: qv vector: qv

Reference

Per the official Azure DocumentDB / Cosmos DB for MongoDB vCore vector-search docs, the cosmosSearch operator shape is:

{
  $search: {
    cosmosSearch: {
      path: "<field>",
      vector: [ /* query embedding */ ],
      k: <int>,
      // optional: lSearch, filter, efSearch (HNSW), nProbes (IVF)
    }
  }
}

Validation

  • pwsh scripts/validate-skills.ps1 still passes (17/17).
  • rg ""cosmosSearch:.*query:"" returns no remaining hits.

The cosmosSearch operator in Azure DocumentDB's $search aggregation
stage takes the query embedding under the �ector field, not query.
The previous examples would fail at runtime (or silently return wrong
results depending on server version), and the agent surfaces these
files verbatim when generating vector-search code.

Fixes three occurrences:
- skills/vector-search/vector-knn-query.md (both the incorrect and
  correct examples)
- skills/full-text-search/fts-hybrid-search.md (vector arm of the
  hybrid example)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@khelanmodi khelanmodi merged commit 59570ac into Azure:main May 26, 2026
3 checks passed
@khelanmodi khelanmodi deleted the fix/cosmossearch-vector-field branch May 26, 2026 21:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants