Create an Index

Use the create index operation to create a vector index on a table to enable fast similarity search.

The operation creates an index for efficient approximate nearest neighbor (ANN) search. The index creation runs asynchronously as a background job.

Both Inverted File Flat (IVF) and Hierarchical Navigable Small World (HNSW) indexes are supported.

See the following for an example of using create_index.

describe_indexdescribe_index_job
from oracle_vecdb import OracleVecDB, Configuration

client = OracleVecDB(Configuration(
    rest_url="https://<host>/ords/<schema>/_/db-api/stable/vecdb/",
    access_token="<bearer-token>", # or username="<user>", password="<pass>"
))

#create an index with default IVF settings
def_ivf_response = client.create_index(table_name='products')
print(def_ivf_response)


#create an HNSW index with custom parameters
hnsw_response = client.create_index(
    table_name='products',
    index_params={
        'vector_index_params': {
            'auto_index': True,
            'organization': 'INMEMORY GRAPH',
            'distance_metric': 'COSINE',
            'quantization_type': 'SCALAR',
            'compression_ratio': 4,
            'distribute_params': {
                'distribute_method': 'AUTO'
            },
            'advanced_params': {
                'neighbors': 32,
                'efConstruction': 200,
                'rescore_factor': 10,
                'algorithm': 'uniform_quantization'
            }
        },
        'metadata_index_params': {
            'auto_index': True,
            'include_paths': ['tenant', 'category'],
            'exclude_paths': ['body']
        },
        'parallel_creation': 4
    }
)
print(hnsw_response)

#Create an IVF index with explicit defaults
ex_ivf_response = client.create_index(
    table_name='products',
    index_params={
        'vector_index_params': {
            'organization': 'PARTITIONS',
            'distance_metric': 'COSINE',
            'advanced_params': {
                'partitions': 16
            }
        }
    }
)
print(ex_ivf_response)


#monitor index creation progress
status = client.describe_index(table_name='products')
print(status)

A JSON response is returned containing the index job ID and status.

For more information about the create_index operation, see Python API Reference.

See how POST /vecdb/vector-indexes/ can be used in the following examples.

  • Create an HNSW index with metadata index paths:
    curl -X POST \
      "https://<host>:<port>/ords/<schema>/_/db-api/stable/vecdb/vector-indexes/" \
      -H "Content-Type: application/json" \
      -H "Accept: application/json" \
      # Choose ONE authentication method:
    
      # Option 1: Basic authentication
      -u "<user>:<password>" \
    
      # Option 2: OAuth Bearer token
      # -H "Authorization: Bearer <access_token>" \
    
      -d '{
        "tableName": "product_vectors",
        "indexParams": {
          "vector_index_params": {
            "auto_index": true,
            "organization": "INMEMORY GRAPH",
            "distance_metric": "COSINE",
            "accuracy": 95,
            "quantization_type": "SCALAR",
            "compression_ratio": 4,
            "advanced_params": {
              "neighbors": 32,
              "efConstruction": 128,
              "rescore_factor": 4,
              "algorithm": "uniform_quantization"
            }
          },
          "metadata_index_params": {
            "auto_index": true,
            "include_paths": ["category", "price"]
          },
          "parallel_creation": 2
        }
      }'
  • Create an IVF index with explicit defaults:
    curl -X POST \
      "https://<host>:<port>/ords/<schema>/_/db-api/stable/vecdb/vector-indexes/" \
      -H "Content-Type: application/json" \
      -H "Accept: application/json" \
      -u "<user>:<password>" \
      -d '{
        "tableName": "product_vectors",
        "indexParams": {
          "vector_index_params": {
            "auto_index": true,
            "organization": "PARTITIONS",
            "distance_metric": "COSINE",
            "advanced_params": {
              "partitions": 16
            }
          },
          "parallel_creation": 2
        }
      }'

Responses:

  • Example 200 response:
    {
      "job_creator": "APPUSER",
      "job_name": "VECDB_CREATE_INDEX_20260501100000",
      "job_type": "PLSQL_BLOCK",
      "operation": "CREATE",
      "state": "SUCCEEDED",
      "start_date": "2026-05-01T10:00:00.302367Z",
      "links": [
        {
          "href": "/vecdb/vector-indexes/jobs/",
          "rel": "collection"
        },
        {
          "href": "/vecdb/vector-indexes/jobs/vecdb_create_index_20260501100000/",
          "rel": "self"
        },
        {
          "href": "/vecdb/vector-indexes/jobs/vecdb_create_index_20260501100000/jobfile",
          "rel": "related"
        }
      ]
    }
  • 400 - the request body included invalid parameters.
  • 404 - the vector table was not found.

For more information about POST /vecdb/vector-indexes/, see REST API Reference.

See how DBMS_VECTOR_DATABASE.CREATE_INDEX can be used in the following example:

dbms_vector_database.create_index(
    table_name => 'product_vectors',
    index_params => JSON('{
      "vector_index_params": {
        "auto_index": true,
        "organization": "INMEMORY GRAPH",
        "distance_metric": "COSINE",
        "accuracy": 95,
        "quantization_type": "SCALAR",
        "compression_ratio": 4,
        "advanced_params": {
          "neighbors": 32,
          "efConstruction": 128,
          "rescore_factor": 4,
          "algorithm": "uniform_quantization"
        }
      },
      "metadata_index_params": {
        "auto_index": true,
        "include_paths": ["category", "price"]
      },
      "parallel_creation": 2
    }')
);
Example response:
{
  "message": "Vector index VECIDX_PRODUCT_VECTORS_20260501T100000 and Metadata index(es) for paths [category, price] created successfully for table PRODUCT_VECTORS"
}

For more about the PL/SQL implementation, including parameters, see CREATE_INDEX.