# Create an AI Search index

Launch stage: Public Preview

`POST /api/2.0/ai-search/{parent=workspaces/*/endpoints/*}/indexes`

Create a new AI Search index. The index is provisioned asynchronously; `status.ready` on
 GetIndex reports when it can serve queries.

API scopes: ai-search

## Path parameters

- `parent` (string, required)
  The Endpoint where this Index will be created.
   Format: `workspaces/{workspace_id}/endpoints/{endpoint_id}`

## Query parameters

- `index_id` (string, optional)
  Three-level Unity Catalog table name for the new index, in the form `catalog.schema.name`.
   The server composes the full `Index.name` as `{parent}/indexes/{index_id}` and rejects an
   empty value.
  Example: `main.default.docs_index`

## Request body

The Index resource to create. Fields other than `index.name` carry the desired
 configuration; `index.name` is server-assigned from `parent` and `index_id`.
- `name` (string, optional, ID, Immutable)
  Name of the AI Search index. Server-assigned full resource path
   (`workspaces/{workspace}/endpoints/{endpoint}/indexes/{index}`) on output, where
   `{index}` is the index's Unity Catalog table name. On create, the user-supplied UC
   table name is conveyed via `CreateIndexRequest.index_id`; the server composes the
   full `name` and returns it on the response.
  Example: `workspaces/1234567890123456/endpoints/docs-endpoint/indexes/main.default.docs_index`
- `primary_key` (string, required, Immutable)
  Name of the column that uniquely identifies each row. It must exist in the source table
   (Delta Sync) or in `schema_json` (Direct Access) and cannot be the embedding source or vector
   column. Set on create and immutable thereafter.
- `index_type` (string, required, Immutable)
  Type of index. A `DELTA_SYNC` index is kept in sync with a source Delta table; a
   `DIRECT_ACCESS` index holds rows that you write through UpsertData and RemoveData. Set on
   create and immutable thereafter.
  Possible values:
  - `DELTA_SYNC`
  - `DIRECT_ACCESS`
- `direct_access_index_spec` (object, optional, Immutable)
  Specification for a Direct Access index. Set when `index_type` is `DIRECT_ACCESS`.
  - `embedding_vector_columns` (array of object, optional)
    Columns that hold precomputed embedding vectors. A single vector column is supported, and it
     cannot be the primary key.
    - `name` (string, optional)
      Name of the column that holds the precomputed embedding vectors.
    - `embedding_dimension` (int32, optional)
      Number of elements in each embedding vector. It must be positive.
  - `schema_json` (string, optional)
    The schema of the index in JSON format, mapping each column name to its type. Supported
     types are `integer`, `long`, `float`, `double`, `boolean`, `string`, `date`, `timestamp`.
     Supported types for vector columns: `array<float>`, `array<double>`. The schema must include
     the primary key column and the embedding vector column.
  - `embedding_source_columns` (array of object, optional)
    Columns that contain the text to embed, each with the model endpoint that computes its
     embeddings.
    - `name` (string, optional)
      Name of the column whose text is embedded.
    - `embedding_model_endpoint` (string, optional)
      Name of the embedding model endpoint, used by default for both ingestion and querying.
    - `model_endpoint_name_for_query` (string, optional)
      Name of the embedding model endpoint which, if specified, is used for querying (not ingestion).
- `delta_sync_index_spec` (object, optional, Immutable)
  Specification for a Delta Sync index. Set when `index_type` is `DELTA_SYNC`.
  - `source_table` (string, optional)
    Three-level Unity Catalog name of the source Delta table, in the form `catalog.schema.table`.
    Example: `main.default.docs`
  - `embedding_source_columns` (array of object, optional)
    Columns whose text Databricks embeds during sync, using the model endpoint named on each
     column. Set either this field or `embedding_vector_columns`, not both.
    - `name` (string, optional)
      Name of the column whose text is embedded.
    - `embedding_model_endpoint` (string, optional)
      Name of the embedding model endpoint, used by default for both ingestion and querying.
    - `model_endpoint_name_for_query` (string, optional)
      Name of the embedding model endpoint which, if specified, is used for querying (not ingestion).
  - `embedding_vector_columns` (array of object, optional)
    Columns of the source table that already hold precomputed embedding vectors. Set either this
     field or `embedding_source_columns`, not both.
    - `name` (string, optional)
      Name of the column that holds the precomputed embedding vectors.
    - `embedding_dimension` (int32, optional)
      Number of elements in each embedding vector. It must be positive.
  - `embedding_writeback_table` (string, optional)
    Three-level name of a Delta table to write the synced rows and computed embeddings to. It
     applies only when embeddings are computed from `embedding_source_columns`, and the table must
     not already exist.
  - `columns_to_sync` (array of string, optional)
    Columns of the source table to include in the index. When empty, all columns are synced. The
     primary key and the embedding source or vector column are always synced. Only synced columns
     can be returned in query results or used in filters.
  - `pipeline_type` (string, required)
    Sync mode of the pipeline that keeps the index up to date. `TRIGGERED` syncs at creation and
     then each time SyncIndex is called; `CONTINUOUS` processes source changes as they arrive.
     Storage Optimized endpoints accept only `TRIGGERED`, and an unset value is rejected.
    Possible values:
    - `TRIGGERED`
    - `CONTINUOUS`
- `index_subtype` (string, optional, Immutable)
  Subtype of the index. Use `HYBRID` for vector and hybrid search, or `FULL_TEXT` for
   keyword-only search without embeddings; `VECTOR` is not a supported create value. Set on
   create and immutable thereafter.
  Possible values:
  - `VECTOR`
  - `FULL_TEXT`
  - `HYBRID`

## Returns

Returns the Index object.

## Request

### Delta Sync index (index_id=main.default.docs_index)

```json
{
  "primary_key": "id",
  "index_type": "DELTA_SYNC",
  "index_subtype": "HYBRID",
  "delta_sync_index_spec": {
    "source_table": "main.default.docs",
    "embedding_source_columns": [
      {
        "name": "text",
        "embedding_model_endpoint": "databricks-gte-large-en"
      }
    ],
    "columns_to_sync": [
      "id",
      "title",
      "text"
    ],
    "pipeline_type": "TRIGGERED"
  }
}
```

### Direct Access index (index_id=main.default.faq_index)

```json
{
  "primary_key": "id",
  "index_type": "DIRECT_ACCESS",
  "direct_access_index_spec": {
    "schema_json": "{\"id\": \"int\", \"question\": \"string\", \"answer\": \"string\", \"answer_vector\": \"array<float>\"}",
    "embedding_vector_columns": [
      {
        "name": "answer_vector",
        "embedding_dimension": 3
      }
    ]
  }
}
```

## Response

### Delta Sync index

```json
{
  "name": "workspaces/1234567890123456/endpoints/docs-endpoint/indexes/main.default.docs_index",
  "endpoint": "docs-endpoint",
  "primary_key": "id",
  "index_type": "DELTA_SYNC",
  "index_subtype": "HYBRID",
  "delta_sync_index_spec": {
    "source_table": "main.default.docs",
    "embedding_source_columns": [
      {
        "name": "text",
        "embedding_model_endpoint": "databricks-gte-large-en"
      }
    ],
    "columns_to_sync": [
      "id",
      "title",
      "text"
    ],
    "pipeline_type": "TRIGGERED",
    "pipeline_id": "f4eaf1c8-28f9-4ad7-a2f2-a6c8f9eb0b0e"
  },
  "status": {
    "message": "Delta sync index creation is pending.",
    "indexed_row_count": 0,
    "ready": false
  },
  "creator": "john@example.com"
}
```

### Direct Access index

```json
{
  "name": "workspaces/1234567890123456/endpoints/docs-endpoint/indexes/main.default.faq_index",
  "endpoint": "docs-endpoint",
  "primary_key": "id",
  "index_type": "DIRECT_ACCESS",
  "direct_access_index_spec": {
    "schema_json": "{\"id\": \"int\", \"question\": \"string\", \"answer\": \"string\", \"answer_vector\": \"array<float>\"}",
    "embedding_vector_columns": [
      {
        "name": "answer_vector",
        "embedding_dimension": 3
      }
    ]
  },
  "status": {
    "message": "Direct access index creation succeeded.",
    "indexed_row_count": 0,
    "ready": true
  },
  "creator": "john@example.com"
}
```

