← Back to APIs
RAG PIPELINE — VECTOR SEARCH

Vector Search

After generating the question embedding (Step 5), pass it to the Azure AI Search Vector Search endpoint. The engine performs an Approximate Nearest Neighbor (ANN) search over the stored embedding vectors and returns the chunks whose vectors are closest to the question vector — i.e., the most semantically similar document chunks regardless of exact keyword overlap.

POST · Azure AI Search ANN Vector Search · k-NN Variables: azureAiSearch_ResourceName, azureAISearch_IndexName, azureAISearch_Key
01

Endpoint

POST https://{{azureAiSearch_ResourceName}}.search.windows.net/indexes/{{azureAISearch_IndexName}}/docs/search?api-version=2025-05-01-preview
02

Postman Collection Variables Required

Set these variables in the Postman collection before calling this API azureAiSearch_ResourceName — Your Azure AI Search resource name
azureAISearch_IndexName — The name of your Azure AI Search index
azureAISearch_Key — Your Azure AI Search API key
03

Authentication

Azure AI Search API Key

Header: api-key{{azureAISearch_Key}}
04

Request Body

FieldTypeRequiredDescription
vectorQueries Array Required Array of vector query objects. Typically contains one query.
vectorQueries[].kind String Required Must be "vector".
vectorQueries[].vector Array<float> Required The 1536-dim embedding vector of the user's question. Copy from the Get Question Embedding response (data[0].embedding).
vectorQueries[].fields String Required The vector field in the index to search against. Use "embedding".
vectorQueries[].k Integer Optional Number of nearest neighbours to return. Default 5. Use 3–5 for RAG context.
select String Optional Comma-separated fields to return, e.g. "section,content".

Request Body Structure

{
  "vectorQueries": [
    {
      "kind"  : "vector",
      "vector": [ 0.0198974609375, 0.055816650390625, ... ],  // 1536 floats from Step 5
      "fields": "embedding",
      "k"     : 5
    }
  ],
  "select": "section,content"
}
05

Sample Request

cURL

curl -X POST \
  -H "api-key: <your-azure-search-key>" \
  -H "Content-Type: application/json" \
  -d '{"vectorQueries":[{"kind":"vector","vector":[0.019,0.055,...],"fields":"embedding","k":5}],"select":"section,content"}' \
  "https://<resource>.search.windows.net/indexes/<index>/docs/search?api-version=2025-05-01-preview"
06

Response — 200 OK

Use content chunks as context for GPT Concatenate the content fields from the returned chunks and pass them as context in the Ask Question to GPT request (Step 7).

Sample Response

{
  "value": [
    {
      "@search.score" : 0.8912,
      "section"       : "Introduction to Azure AI Search",
      "content"       : "Azure AI Search is a fully managed, cloud-based search service..."
    },
    // more chunks...
  ]
}
07

Error Responses

200
OK — Top-k nearest chunks returned by vector similarity.
400
Bad Request — Vector dimension mismatch (must match the index's embedding field dimension), or fields not a vector field.
401
Unauthorized — Invalid or missing api-key.
404
Not Found — Index not found.