---
title: Databricks AI Search
description: Databricks AI Search (formerly Vector Search) is a vector search engine built into the Data + AI Platform, powering RAG, recommender, and semantic search apps.
canonical_url: https://docs.databricks.com/aws/en/ai-search/ai-search
---

# Databricks AI Search

Databricks AI Search (formerly Databricks Vector Search) is a search solution that is built into the Databricks Data + AI Platform and integrated with its governance and productivity tools. It powers retrieval for AI applications such as RAG systems, recommender systems, and image and video recognition by finding the embeddings most similar to a query.

Vector search is a type of search optimized for retrieving embeddings. Embeddings are mathematical representations of the semantic content of data, typically text or image data. Embeddings are generated by a large language model and are a key component of many AI applications that depend on finding documents or images that are similar to each other.

With Databricks AI Search, you create an AI Search index from a source table, which can be a Delta Lake table, streaming table, materialized view, or managed table using [Iceberg v3](https://docs.databricks.com/aws/en/iceberg/iceberg-v3.md) or above. The index includes embedded data with metadata. You can then query the index using a REST API to identify the most similar vectors and return the associated documents. You can structure the index to automatically sync when the underlying source table is updated.

AI Search supports the following:

* [Hybrid keyword-similarity search](https://docs.databricks.com/aws/en/ai-search/ai-search.md#hybrid).
* [Full-text keyword search (Beta)](https://docs.databricks.com/aws/en/ai-search/query-ai-search.md) on any endpoint, or [dedicated full-text indexes (Beta)](https://docs.databricks.com/aws/en/ai-search/create-ai-search.md#create-full-text-index) on storage-optimized endpoints.
* [Filtering](https://docs.databricks.com/aws/en/ai-search/query-ai-search.md#filters).
* [Reranking](https://docs.databricks.com/aws/en/ai-search/query-ai-search.md#rerank).
* [Query payload logging (Beta)](https://docs.databricks.com/aws/en/ai-search/query-ai-search.md#query-payload-logging) for monitoring and retrieval quality analysis.
* [Access control lists (ACLs) to manage AI Search endpoints](https://docs.databricks.com/aws/en/security/auth/access-control/index.md#vector-search-endpoints).
* [Sync only selected columns](https://docs.databricks.com/aws/en/ai-search/create-ai-search.md#create-vector-search-index).
* [Save and sync generated embeddings](https://docs.databricks.com/aws/en/ai-search/create-ai-search.md#create-vector-search-index).

## <a id="hybrid" />How does AI Search work?

AI Search uses the Hierarchical Navigable Small World (HNSW) algorithm for its approximate nearest neighbor (ANN) searches and the L2 distance metric to measure embedding vector similarity. If you want to use cosine similarity you need to normalize your datapoint embeddings before feeding them into the vector search algorithm. When the data points are normalized, the ranking produced by L2 distance is the same as the ranking produced by cosine similarity.

AI Search also supports hybrid keyword-similarity search, which combines vector-based embedding search with traditional keyword-based search techniques. This approach matches exact words in the query while also using a vector-based similarity search to capture the semantic relationships and context of the query.

By integrating these two techniques, hybrid keyword-similarity search retrieves documents that contain not only the exact keywords but also those that are conceptually similar, providing more comprehensive and relevant search results. This method is particularly useful in RAG applications where source data has unique keywords such as SKUs or identifiers that are not well suited to pure similarity search.

For details about the API, see the [Python SDK reference](https://api-docs.databricks.com/python/ai-search/databricks.ai_search.html) and [Query an AI Search index](https://docs.databricks.com/aws/en/ai-search/query-ai-search.md).

### Similarity search calculation

The similarity search calculation uses the following formula:

![reciprocal of 1 plus the squared distance](https://docs.databricks.com/aws/en/images/generative-ai/similarity-score.png)

where `dist` is the Euclidean distance between the query `q` and the index entry `x`:

![Eucidean distance, square root of the sum of squared differences](https://docs.databricks.com/aws/en/images/generative-ai/euclidean-distance.png)

### Keyword search algorithm

Relevance scores are calculated using [Okapi BM25](https://en.wikipedia.org/wiki/Okapi_BM25). All text or string columns are searched, including the source text embedding and metadata columns in text or string format. The tokenization function splits at word boundaries, removes punctuation, and converts all text to lowercase.

### How similarity search and keyword search are combined

The similarity search and keyword search results are combined using the Reciprocal Rank Fusion (RRF) function.

RRF first rescores each document from each method using the scores:

![RRF equation for ANN](https://docs.databricks.com/aws/en/images/generative-ai/rrf-equation-ann.png)

![RRF equation for keyword search](https://docs.databricks.com/aws/en/images/generative-ai/rrf-equation-keyword.png)

`rrf_param` controls the relative importance of higher-ranked and lower-ranked documents. Based on the literature, `rrf_param` is set to 60.

Scores are normalized so that the highest possible score is 1 using the following normalization factor:

![normalization](https://docs.databricks.com/aws/en/images/generative-ai/rrf-normalization.png)

The final score for each document is calculated as follows:

![final score](https://docs.databricks.com/aws/en/images/generative-ai/final-score.png)

The documents with the highest final scores are returned.

## <a id="options-for-providing-vector-embeddings" />Options for providing vector embeddings

To create an AI Search index in Databricks, you must first decide how to provide vector embeddings. Databricks supports three options.

### Option 1: Delta Sync Index with embeddings computed by Databricks

With this option, use a source that contains data in text format. Supported source types include Delta Lake tables, streaming tables, materialized views, or managed tables using Iceberg v3 or above. Databricks calculates the embeddings, using a model that you specify, and optionally saves the embeddings to a table in Unity Catalog. As the source is updated, the index stays synced with it.

The following diagram illustrates the process:

1. Calculate query embeddings. Query can include metadata filters.
2. Perform similarity search to identify most relevant documents.
3. Return the most relevant documents and append them to the query.

![AI Search index, Databricks calculates embeddings](https://docs.databricks.com/aws/en/images/generative-ai/calculate-embeddings.png)

### Option 2: Delta Sync Index with self-managed embeddings

With this option, use a source that contains pre-calculated embeddings. Supported source types include Delta Lake tables, streaming tables, materialized views, or managed tables using Iceberg v3 or above. As the source is updated, the index stays synced with it.

> [!NOTE]
>
> It is not possible to convert a self-managed embedding index to a Databricks-managed index. If you later decide to use managed embeddings, you must create a new index and recompute embeddings.

The following diagram illustrates the process:

1. Query consists of embeddings and can include metadata filters.
2. Perform similarity search to identify most relevant documents. Return the most relevant documents and append them to the query.

![AI Search index, precalculated embeddings](https://docs.databricks.com/aws/en/images/generative-ai/precalculated-embeddings.png)

### Option 3: Direct Vector Access Index

With this option, you must manually update the index using the REST API when the embeddings table changes. Direct Vector Access indexes are available only on standard endpoints. See [Storage-optimized endpoints limitations](https://docs.databricks.com/aws/en/ai-search/ai-search.md#so-endpoints-limitations).

The following diagram illustrates the process:

![AI Search index, precalculated embeddings with no automatic sync](https://docs.databricks.com/aws/en/images/generative-ai/precalculated-embeddings-no-sync.png)

### Option 4: Full-text search index on storage-optimized endpoints (Beta)

With this option, you create a Delta Sync Index on a storage-optimized endpoint without any embedding columns. The index supports keyword-based full-text search using BM25 scoring, without requiring vector embeddings. This is useful for searching exact terms, identifiers, or keywords in text data.

> [!NOTE]
>
> You can also use `query_type="FULL_TEXT"` to perform keyword searches on existing AI Search indexes on both standard and storage-optimized endpoints. This option is for creating a dedicated index that contains no embeddings at all.

Dedicated full-text search indexes are only available on storage-optimized endpoints and require triggered sync mode. See [Create a full-text search index (Beta)](https://docs.databricks.com/aws/en/ai-search/create-ai-search.md#create-full-text-index) for instructions.

## <a id="endpoint-options" /> Endpoint options

AI Search provides the following options so you can select the endpoint configuration that meets the needs of your application.

> [!NOTE]
>
> High QPS is available for standard endpoints only.

* **Standard** endpoints have a capacity of 320 million vectors at dimension 768.
  * With standard endpoints, you can use high QPS to support high sustained throughput. See [Scale AI Search endpoint throughput with high QPS](https://docs.databricks.com/aws/en/ai-search/high-qps.md).
* **Storage-optimized** endpoints have a larger capacity (over one billion vectors at dimension 768) and provide 10-20x faster indexing. Queries on storage-optimized endpoints have a slightly increased latency of about 250msec. Pricing for this option is optimized for the larger number of vectors. For pricing details, see the [AI Search pricing page](https://www.databricks.com/product/pricing/vector-search). For information on managing AI Search costs, see [AI Search cost management guide](https://docs.databricks.com/aws/en/ai-search/cost-management.md).

You specify the endpoint type when you create the endpoint.

See also [Storage-optimized endpoints limitations](https://docs.databricks.com/aws/en/ai-search/ai-search.md#so-endpoints-limitations).

## How to set up AI Search

To use AI Search, you must create the following:

* An AI Search endpoint. This endpoint serves the AI Search index. You can query and update the endpoint using the REST API or the SDK. See [Create an AI Search endpoint](https://docs.databricks.com/aws/en/ai-search/create-ai-search.md#create-ai-search-endpoint) for instructions.

  Endpoints scale up automatically to support the size of the index or the number of concurrent requests. Endpoints scale down automatically when an index is deleted.

* An AI Search index. With an AI Search index, you can use real-time approximate nearest neighbor (ANN) searches on a source table or view. Supported source types include Delta Lake tables, streaming tables, materialized views, or managed tables using Iceberg v3 or above. The goal of the search is to identify documents that are similar to the query. AI Search indexes appear in and are governed by Unity Catalog. See [Create an AI Search index](https://docs.databricks.com/aws/en/ai-search/create-ai-search.md#create-vector-search-index) for instructions.

In addition, if you choose to have Databricks compute the embeddings, you can use a pre-configured Foundation Model APIs endpoint or create a model serving endpoint to serve the embedding model of your choice. See [Pay-per-token Foundation Model APIs](https://docs.databricks.com/aws/en/machine-learning/foundation-model-apis/index.md#token-foundation-apis) or [Create foundation model serving endpoints](https://docs.databricks.com/aws/en/machine-learning/model-serving/create-foundation-model-endpoints.md) for instructions.

To query the model serving endpoint, you use either the REST API or the Python SDK. Your query can define filters based on any column in the source table. For details, see [Use filters on queries](https://docs.databricks.com/aws/en/ai-search/query-ai-search.md#filters), the [API reference](https://docs.databricks.com/api/workspace/vectorsearchendpoints), or the [Python SDK reference](https://api-docs.databricks.com/python/ai-search/databricks.ai_search.html).

### <a id="vector-search-names" />API and tool names

Many AI Search APIs and tools use the former product name, Vector Search, in paths and identifiers. These are the current interfaces for AI Search, and you can use them in new code and automation:

* **REST API**: `/api/2.0/vector-search/endpoints` and `/api/2.0/vector-search/indexes`. See the [Endpoints API reference](https://docs.databricks.com/api/workspace/vectorsearchendpoints) and the [Indexes API reference](https://docs.databricks.com/api/workspace/vectorsearchindexes).
* **SDKs and CLI**: the `VectorSearchEndpoints` and `VectorSearchIndexes` services in each Databricks SDK, and the `vector-search-endpoints` and `vector-search-indexes` command groups in the Databricks CLI.
* **Infrastructure as code**: the `vector_search_endpoints` resource in Declarative Automation Bundles and the `databricks_vector_search_endpoint` and `databricks_vector_search_index` resources in Terraform.
* **SQL and audit logs**: the `vector_search()` SQL function and `service_name = 'vectorSearch'` in audit logs.

The AI Search Python SDK (`databricks-ai-search`) uses AI Search class names, such as `AISearchClient`, and calls the same REST API.

## Requirements

* Unity Catalog enabled workspace.
* Serverless compute enabled. For instructions, see [Connect to serverless compute](https://docs.databricks.com/aws/en/compute/serverless/index.md).
* For [standard endpoints](https://docs.databricks.com/aws/en/ai-search/ai-search.md#endpoint-options), the source table must use a change data feed. See [Use change data feed on Databricks](https://docs.databricks.com/aws/en/tables/features/change-data-feed.md). Tables with [row tracking](https://docs.databricks.com/aws/en/tables/features/row-tracking.md) enabled use a change data feed automatically, without requiring manual configuration. This applies to Delta Lake tables, materialized views with external metadata enabled, and managed tables using Iceberg v3 or above.
* If the source is a materialized view, you must first enable external metadata (also called Smart Clone) on the materialized view or on the pipeline that defines it. See [How to enable access for a dataset](https://docs.databricks.com/aws/en/external-access/external-for-pipelines.md#enable).
* To create an AI Search index, you must have CREATE TABLE privileges on the catalog schema where you create the index.

Permission to create and manage AI Search endpoints is configured using access control lists. See [AI Search endpoint ACLs](https://docs.databricks.com/aws/en/security/auth/access-control/index.md#vector-search-endpoints).

## <a id="authentication" />Data protection and authentication

Databricks implements the following security controls to protect your data:

* Every customer request to AI Search is logically isolated, authenticated, and authorized.
* AI Search encrypts all data at rest (AES-256) and in transit (TLS 1.2+).

AI Search supports two modes of authentication, service principals and personal access tokens (PATs). For production applications, Databricks recommends that you use service principals, which can have a per-query performance up to 100 ms faster relative to personal access tokens.

* Service principal token. An admin can generate a service principal token and pass it to the SDK or API. See [use service principals](https://docs.databricks.com/aws/en/admin/users-groups/service-principals.md). For production use cases, Databricks recommends using a service principal token. For setup steps and required permissions, see [Set up a service principal](https://docs.databricks.com/aws/en/ai-search/high-qps.md#service-principal).

  ```python
  # Pass in a service principal
  vsc = AISearchClient(workspace_url="...",
          service_principal_client_id="...",
          service_principal_client_secret="..."
          )
  ```

* Personal access token. You can use a personal access token to authenticate with AI Search. See [personal access authentication token](https://docs.databricks.com/aws/en/dev-tools/auth/pat.md). If you use the SDK in a notebook environment, the SDK automatically generates a PAT token for authentication.

  ```python
  # Pass in the PAT token
  client = AISearchClient(workspace_url="...", personal_access_token="...")
  ```

[Customer Managed Keys (CMK)](https://docs.databricks.com/aws/en/security/keys/customer-managed-keys.md) are supported on endpoints created on or after May 8, 2024.

## Monitor usage and costs

For information about monitoring usage and costs associated with AI Search indexes and endpoints, see [AI Search cost management guide](https://docs.databricks.com/aws/en/ai-search/cost-management.md).

You can also query usage by usage policy. See [AI Search usage policies](https://docs.databricks.com/aws/en/ai-search/budget-policies.md).

To monitor endpoint health, query rate, latency, errors, and ingestion rate, see [Monitor AI Search endpoints](https://docs.databricks.com/aws/en/ai-search/monitor-endpoints.md).

## Resource and data size limits

The following table summarizes resource and data size limits for AI Search endpoints and indexes:

| Resource                                | Granularity                    | Limit                                                                                                                                                                         |
| --------------------------------------- | ------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| AI Search endpoints                     | Per workspace                  | 500                                                                                                                                                                           |
| Embeddings (Delta Sync index)           | Per standard endpoint          | \~ 320,000,000 at 768 embedding dimension<br />\~ 160,000,000 at 1536 embedding dimension<br />\~ 80,000,000 at 3072 embedding dimension<br />(scales approximately linearly) |
| Embeddings (Direct Vector Access index) | Per standard endpoint          | \~ 2,000,000 at 768 embedding dimension                                                                                                                                       |
| Embeddings (storage-optimized endpoint) | Per storage-optimized endpoint | \~ 1,000,000,000 at 768 embedding dimension                                                                                                                                   |
| Embedding dimension                     | Per index                      | 4096                                                                                                                                                                          |
| Indexes                                 | Per endpoint                   | 50                                                                                                                                                                            |
| Columns                                 | Per index                      | 50                                                                                                                                                                            |
| Columns                                 |                                | Supported types: Bytes, short, integer, long, float, double, boolean, string, timestamp, date, array, struct, map                                                             |
| Metadata fields                         | Per index                      | 50                                                                                                                                                                            |
| Index name                              | Per index                      | 128 characters                                                                                                                                                                |

The following limits apply to the creation and update of AI Search indexes:

| Resource                                               | Granularity | Limit       |
| ------------------------------------------------------ | ----------- | ----------- |
| Row size for Delta Sync Index                          | Per index   | 100KB       |
| Embedding source column size for Delta Sync index      | Per Index   | 32764 bytes |
| Bulk upsert request size limit for Direct Vector index | Per Index   | 10MB        |
| Bulk delete request size limit for Direct Vector index | Per Index   | 10MB        |

The following limits apply to the query API.

| Resource                                                                 | Granularity       | Limit                           |
| ------------------------------------------------------------------------ | ----------------- | ------------------------------- |
| Query text length                                                        | Per query         | 32764 characters                |
| Tokens when using hybrid search                                          | Per query         | 1024 words or 2-byte characters |
| Filter conditions                                                        | Per filter clause | 1024 elements                   |
| Maximum number of results returned (approximate nearest neighbor search) | Per query         | 10,000                          |
| Maximum number of results returned (hybrid keyword-similarity search)    | Per query         | 200                             |
| Maximum number of results returned (full-text search)                    | Per query         | 10,000                          |
| Response size                                                            | Per query         | 10MB                            |

## Limitations

* Struct and map columns have the following limitations:
  * Struct fields must resolve to primitive values.
  * Arrays and maps can't be nested inside structs. `ARRAY<STRUCT>` isn't supported.
  * Maps must be top-level columns with string keys and primitive values.
* The column name `_id` is reserved. If your source table has a column named `_id`, rename it before creating an AI Search index.
* Row and column level permissions are not supported. However, you can implement your own application level ACLs using the filter API.
* You cannot clone an index into a different workspace. You can make cross-workspace requests using the Databricks SDK or REST API.
* Index capacity is provisioned based on the source table size at index creation time. Starting with a small source table limits how much the index can grow and can result in capacity-exhausted errors, so size the source table to match your expected data volume before creating the index.

### <a id="so-endpoints-limitations" />Storage-optimized endpoints limitations

The limitations in this section apply only to [storage-optimized endpoints](https://docs.databricks.com/aws/en/ai-search/ai-search.md#endpoint-options).

* Continuous sync mode is not supported.
* Columns to sync is not supported.
* Direct Vector Access indexes are not supported. Use a standard endpoint for a Direct Vector Access index.
* Embedding dimension must be divisible by 16.
* Incremental update is partially supported. Every sync must rebuild portions of the AI Search index.
  * For managed indexes, any embeddings previously computed are reused if the source row has not changed.
  * You should anticipate a significant end-to-end reduction in time required for a sync compared to the standard endpoints. Datasets with 1 billion embeddings should complete a sync in under 8 hours. Smaller datasets will take less time to sync.
* FedRAMP compliant workspaces are not supported.
* To use a custom embedding model for a managed Delta Sync index, the [AI Query for Custom Models and External Models](https://docs.databricks.com/aws/en/sql/language-manual/functions/ai_query.md) preview must be enabled. See [Manage Databricks previews](https://docs.databricks.com/aws/en/admin/workspace-settings/manage-previews.md) to learn how to enable previews.
* Storage-optimized endpoints support up to 1 billion embeddings of vectors of 768 dimensions. If you have a larger scale use case, reach out to your account team.

## Additional resources

* [Deploy Your LLM Chatbot With Retrieval Augmented Generation (RAG), Foundation Models and AI Search](https://www.databricks.com/resources/demos/tutorials/data-science-and-ai/lakehouse-ai-deploy-your-llm-chatbot).
* [Create AI Search endpoints and indexes](https://docs.databricks.com/aws/en/ai-search/create-ai-search.md)
* [Query an AI Search index](https://docs.databricks.com/aws/en/ai-search/query-ai-search.md)
* [AI Search example notebooks](https://docs.databricks.com/aws/en/ai-search/example-notebooks.md)
