TATECHATLAS
◎ English
Artificial intelligence / Guide

Configuring Hybrid Search with Vector and Text Fields in Azure AI Search

Step-by-step guide to creating an index, generating embeddings, and executing hybrid queries that combine full-text and vector search using Azure AI Search.

On this page

Hybrid search is configured by adding vector fields to the index schema, generating embeddings for textual content, and forming a query with search and vectorQueries parameters. Results are merged using Reciprocal Rank Fusion (RRF), and optionally a semantic reranker can be enabled for re-ranking. Key steps: index schema definition, embedding generation, k and oversampling configuration, query construction with filters and facets, optional semantic reranker inclusion, testing, and monitoring quotas and costs.

1. Index Schema Definition with Vector and Text Fields

To begin, an Azure AI Search index is created containing both regular text fields for full-text search and vector fields for semantic search. Vector fields store numeric embeddings derived from document text. The index must have at least one searchable text field and one vector field. When creating an index via the portal or REST API, vector fields are declared with type "Collection(Edm.Single)" and the "searchable": true attribute, but they are not used for ordinary full-text search; their role is vector similarity.

An example from Microsoft Learn documentation shows a hybrid query where the search parameter is combined with vectorQueries pointing to DescriptionVector and Description_frVector fields. This allows a single query to perform both keyword search and semantic search, with results merged by the RRF algorithm.

Important: vector fields cannot be used directly in filters. For metadata (e.g., category, geography) a separate text or numeric field marked with filterable and/or facetable attributes is required.

{
  "name": "DescriptionVector",
  "type": "Collection(Edm.Single)",
  "searchable": true,
  "dimensions": 1536,
  "vectorSearchProfile": "my-vector-profile",
  "filterable": false,
  "facetable": false,
  "sortable": false
}

2. Generating or Importing Embeddings for Text Fields

Embeddings can be generated in two ways: using Azure AI Search built-in capabilities (indexer pipeline with Azure OpenAI) or external models (OpenAI embeddings, SBERT, etc.) and then loading vectors directly into the index. In the first case, a skillset is configured that automatically chunks text and calls the embedding model. In the second case, vectors are formed externally and passed via API when creating or updating documents.

Choose an embedding model supported by your environment; Ada is one example, not a required or universally preferred model. Use the same model and compatible dimensions for indexed documents and query vectors. Matching array length alone does not make vectors from different models comparable.

Integrated vectorization requires a configured ingestion pipeline and supported embedding skill or vectorizer. A portal wizard is a configuration aid, not a guarantee that an arbitrary existing index already contains valid embeddings.

3. Configuring Vector Search Parameters (k, oversampling, exhaustive)

k controls the number of vector candidates; top controls the maximum returned document count. With semantic ranking, start with k=50 to supply candidates, then assess the actual results on your corpus. Increasing k does not guarantee a better answer.

oversampling is a multiplier for additional candidates used with compressed vector fields and rescoring, not a percentage or a general HNSW tuning switch. A factor of 20 with k=5 means up to 100 candidates before rescoring and reduction to k. Check the compression configuration and API version before using it.

exhaustive=true requests exhaustive nearest-neighbor search. It can help compare approximate retrieval against vector-distance ground truth, but does not prove business relevance. Exhaustive search does not use HNSW rescoring or oversampling. The simple query below therefore omits oversampling; evaluate approximate and exhaustive modes separately.

4. Forming a Hybrid Query with search and vectorQueries

A hybrid query combines the search parameter (full-text query) and one or more vectorQueries. The request is sent as a single HTTP POST message to the index endpoint with api-version=2026-04-01 (or current version).

The server executes full-text and vector searches in parallel, then merges results using the Reciprocal Rank Fusion (RRF) algorithm. RRF assigns each document a combined rank based on its position in both result lists, allowing combination of precise keyword search and semantic similarity advantages.

In the query, queryType: semantic can be specified to enable the semantic reranker, which applies machine reading to RRF results and re-ranks them based on query context. This is particularly useful for conceptual queries where meaning matters more than word matching.

Filtering does not simply occur after RRF. vectorFilterMode controls the vector retrieval branch; the text branch also observes its filter criteria. The ranking fusion combines the resulting candidate lists. Examine both branches when eligible documents are missing.

The Python function builds a request body; it does not call Azure or generate embeddings. Pass the query text, its real embedding and the dimension count from your index. A length mismatch raises ValueError. Otherwise the returned body has both search and vectorQueries, explicitly uses preFilter, and requests at most ten returned documents. Serialize it as JSON and POST it to your index search endpoint with an API version and authentication supported by your service. The schema fragment above is only one field; a complete index also needs a key, text fields and the named vector profile.

def hybrid_request(query_text, query_vector, dimensions):
    if len(query_vector) != dimensions:
        raise ValueError("Embedding dimension mismatch")
    return {
        "search": query_text,
        "select": "HotelId, HotelName, Description",
        "vectorFilterMode": "preFilter",
        "vectorQueries": [{
            "kind": "vector",
            "vector": query_vector,
            "fields": "DescriptionVector",
            "k": 50,
        }],
        "top": 10,
    }

5. Applying Filters and Facets on Non-Vector Fields

Define the filter on nonvector metadata fields marked filterable, such as Category or a location field. Facets use fields marked facetable; a vector field itself is neither filterable nor facetable. Treat filtering and faceting as separate configuration requirements.

preFilter is the default for indexes created after approximately October 15, 2023; older indexes can have a different default and may require recreation to support it. With HNSW, preFilter applies the predicate during graph traversal. postFilter filters local candidates on each shard before their aggregation, so selective filters or small k can miss eligible documents.

Set the mode explicitly in the request and compare returned identifiers with the intended eligible set. A filter is not a semantic relevance score, and postFilter is not inherently more relevant. When fewer than top documents arrive, check the number of eligible candidates before changing ranking parameters.

{
  "filter": "Category eq 'Luxury'",
  "vectorFilterMode": "preFilter"
}

6. Optionally: Enabling Semantic Reranker for Re-ranking

Semantic reranker is available by adding queryType: semantic and specifying semanticConfiguration in the request. The reranker uses machine reading to analyze fused RRF results and re-rank them based on semantic correspondence to the query.

Semantic ranking is an optional second ranking stage, not a promise of improvement for every corpus. Compare the returned identifiers and relevance judgments for the same held-out questions, with and without the feature. Its score is not a probability that a document is correct.

Semantic reranker configuration is set at the index level (section "semantic configurations"). In the request, the configuration name is indicated, as well as the query language (queryLanguage).

If the semantic reranker is not needed, a request can be sent without queryType: semantic. In this case results are ranked only based on RRF, combining BM25 (for text) and HNSW/eKNN (for vectors).

{
  "queryType": "semantic",
  "semanticConfiguration": "my-semantic-config"
}

7. Testing and Iterating k, oversampling and Filter Behavior

After deployment, it is necessary to experiment with k, oversampling and filter behavior (preFilter/postFilter) to find the optimal speed-accuracy ratio for your domain.

Vary one setting at a time, keeping the query set and relevance judgments fixed. Examine k and the filtering mode first. Try oversampling only for a compatible compressed HNSW field; omit it for exhaustive retrieval.

Compare results with and without semantic reranker. If k is too small, the semantic reranker will not receive enough candidates, and re-ranking will be less effective.

Measure end-to-end latency under the same load while changing candidate counts. More candidates can increase work, but no universal latency increase or accuracy gain follows from a particular value. Select a configuration using your own relevance and latency requirements.

Use Azure Portal or REST API debugging tools: parameter count: true allows seeing total match count, and @search.rerankerScore field shows the semantic reranker evaluation.

8. Deployment and Monitoring Vector Index Quotas and Costs

Inspect the actual service tier, region, index limits and current vector storage usage. Creation date alone is not an API version or proof of available quota. Consult the service portal and current limits before a large import.

Generating embeddings through Azure OpenAI or other models incurs charges from the model provider. These costs should be considered when planning data volume and update frequency.

Check index and vector storage usage in the service portal, alongside indexing errors and query diagnostics. Do not use an invented GET request to the service root as a quota check.

For hybrid search, monitor query latency: large k and oversampling increase load. If latency becomes unacceptable, reduce oversampling or recheck HNSW configuration.

It is recommended to set up quota exceeded alerts and regularly check index state, especially after large document batches.

Things to check

  • Index contains at least one searchable text field and one vector field with matching embedding dimensionality.
  • Embeddings are generated and loaded into vector fields (via indexer or direct API).
  • Hybrid query includes search and vectorQueries with correct k and fields values.
  • When using semantic reranker, queryType: semantic and semanticConfiguration are set.
  • Filters and facets reference text/numeric fields, not vector fields directly.
  • Actual service and index quotas, supported API version and current vector storage usage have been checked.
  • Cost monitoring for embeddings and query latency is enabled.

Vector fields cannot be used directly in filters. For metadata (e.g., category, geography) a separate text or numeric field marked with filterable and/or facetable attributes is required.

Sources

  1. Microsoft Learn: hybrid search ↗
  2. Microsoft Learn: vector index schema ↗
  3. Microsoft Learn: vector filters ↗
  4. Microsoft Learn: vector compression and rescoring ↗
Back to top ↑