# Create

Launch stage: GA

`POST /api/2.0/vector-search/indexes`

Create a new index.

API scopes: vector-search

## Request body

- `name` (string, optional)
  Name of the index
- `endpoint_name` (string, optional)
  Name of the endpoint to be used for serving the index
- `primary_key` (string, optional)
  Primary key of the index
- `index_type` (string, optional)
  Possible values: `DELTA_SYNC`, `DIRECT_ACCESS`
- `direct_access_index_spec` (object, required)
  Specification for Direct Vector Access Index. Required if `index_type` is `DIRECT_ACCESS`.
  - `embedding_vector_columns` (array of object, optional)
    The columns that contain the embedding vectors. The format should be array[double].
    - `name` (string, optional)
      Name of the column
    - `embedding_dimension` (int32, optional)
      Dimension of the embedding vector
  - `schema_json` (string, optional)
    The schema of the index in JSON format.
     Supported types are `integer`, `long`, `float`, `double`, `boolean`, `string`, `date`, `timestamp`.
     Supported types for vector column: `array<float>`, `array<double>`,`.
  - `embedding_source_columns` (array of object, optional)
    The columns that contain the embedding source. The format should be array[double].
    - `name` (string, optional)
      Name of the column
    - `embedding_model_endpoint_name` (string, required)
      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, required)
  Specification for Delta Sync Index. Required if `index_type` is `DELTA_SYNC`.
  - `source_table` (string, optional)
    The name of the source table.
  - `embedding_source_columns` (array of object, optional)
    The columns that contain the embedding source.
    - `name` (string, optional)
      Name of the column
    - `embedding_model_endpoint_name` (string, required)
      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)
    The columns that contain the embedding vectors.
    - `name` (string, optional)
      Name of the column
    - `embedding_dimension` (int32, optional)
      Dimension of the embedding vector
  - `pipeline_type` (string, optional)
    Pipeline execution mode.
     - `TRIGGERED`: If the pipeline uses the triggered execution mode, the system stops processing after successfully refreshing the source table in the pipeline once, ensuring the table is updated based on the data available when the update started.
     - `CONTINUOUS`: If the pipeline uses continuous execution, the pipeline processes new data as it arrives in the source table to keep vector index fresh.
    Possible values: `TRIGGERED`, `CONTINUOUS`
  - `pipeline_id` (string, optional)
    The ID of the pipeline that is used to sync the index.
  - `embedding_writeback_table` (string, optional)
    [Optional] Name of the Delta table to sync the vector index contents and computed embeddings to.
  - `columns_to_sync` (array of string, optional)
    [Optional] Select the columns to sync with the vector index. If you leave this field blank, all columns
     from the source table are synced with the index. The primary key column and embedding source column or
     embedding vector column are always synced.
  - `columns_to_index` (array of string, optional)
    [Optional] Alias for columns_to_sync. Select the columns to include in the vector index.
     If you leave this field blank, all columns from the source table are included.
     The primary key column and embedding source column or embedding vector column are always included.
     Only one of columns_to_sync or columns_to_index may be specified.
- `index_subtype` (string, optional, Beta)
  The subtype of the index. Use `HYBRID` or `FULL_TEXT`. `VECTOR` is not supported.
  Possible values: `VECTOR`, `FULL_TEXT`, `HYBRID`

## Returns

Returns the VectorIndex object.

## Request

### Create a Delta Sync Index

```json
{
  "delta_sync_index_spec": {
    "columns_to_sync": [
      "id",
      "text"
    ],
    "embedding_source_columns": [
      {
        "embedding_model_endpoint_name": "e5-small-v2",
        "name": "text"
      }
    ],
    "pipeline_type": "TRIGGERED",
    "source_table": "main_catalog.docs.en_wiki"
  },
  "index_type": "DELTA_SYNC",
  "name": "main_catalog.docs.en_wiki_index",
  "primary_key": "id"
}
```

### Create a Direct Vector Access Index

```json
{
  "direct_access_index_spec": {
    "embedding_vector_columns": [
      {
        "embedding_dimension": 1024,
        "name": "text_vector"
      }
    ],
    "schema_json": "{\"id\":\"int\",\"text\":\"string\",\"text_vector\":\"array<float>\"}"
  },
  "index_type": "DIRECT_ACCESS",
  "name": "main_catalog.docs.en_wiki_index",
  "primary_key": "id"
}
```

## Response

### Successful response for Delta Sync Index

```json
{
  "creator": "john@example.com",
  "delta_sync_index_spec": {
    "columns_to_sync": [
      "id",
      "text"
    ],
    "embedding_source_columns": [
      {
        "embedding_model_endpoint_name": "e5-small-v2",
        "name": "text"
      }
    ],
    "pipeline_id": "f4eaf1c8-28f9-4ad7-a2f2-a6c8f9eb0b0e",
    "pipeline_type": "TRIGGERED",
    "source_table": "main_catalog.docs.en_wiki"
  },
  "endpoint_name": "docs-endpoint",
  "index_type": "DELTA_SYNC",
  "name": "main_catalog.docs.en_wiki_index",
  "primary_key": "id",
  "status": {
    "index_url": "demo.cloud.databricks.com/api/2.0/vector-search/endpoints/docs-endpoint/indexes/main_catalog.docs.en_wiki_index",
    "indexed_row_count": 0,
    "message": "Delta sync Index creation is pending. Check latest status in Delta Live Tables: https://demo.cloud.databricks.com#joblist/pipelines/f4eaf1c8-28f9-4ad7-a2f2-a6c8f9eb0b0e",
    "ready": false
  }
}
```

### Successful response for Direct Vector Access Index

```json
{
  "creator": "john@example.com",
  "direct_access_index_spec": {
    "embedding_vector_columns": [
      {
        "embedding_dimension": 1024,
        "name": "text_vector"
      }
    ],
    "schema_json": "{\"id\":\"int\",\"text\":\"string\",\"text_vector\":\"array<float>\"}"
  },
  "endpoint_name": "docs-endpoint",
  "index_type": "DIRECT_ACCESS",
  "name": "main_catalog.docs.en_wiki_index",
  "primary_key": "id",
  "status": {
    "index_url": "demo.cloud.databricks.com/api/2.0/vector-search/endpoints/docs-endpoint/indexes/main_catalog.docs.en_wiki_index",
    "indexed_row_count": 0,
    "message": "Direct access index creation succeeded.",
    "ready": true
  }
}
```

