CREATE_INDEX
Use the DBMS_VECTOR.CREATE_INDEX procedure to create a
vector index.
Purpose
To create a vector index such as Hierarchical Navigable Small World (HNSW) vector index or Inverted File Flat (IVF) vector index.
Syntax
DBMS_VECTOR.CREATE_INDEX (
idx_name IN VARCHAR2,
table_name IN VARCHAR2,
idx_vector_col IN VARCHAR2,
idx_include_cols IN VARCHAR2 DEFAULT NULL,
idx_partitioning_scheme IN VARCHAR2 DEFAULT 'LOCAL',
idx_organization IN VARCHAR2,
idx_distance_metric IN VARCHAR2 DEFAULT 'COSINE',
idx_accuracy IN NUMBER DEFAULT 90,
idx_parameters IN CLOB,
idx_parallel_creation IN NUMBER DEFAULT 1,
idx_quantization_type IN VARCHAR2 DEFAULT 'NONE',
idx_compression_ratio IN NUMBER DEFAULT NULL,
idx_distribute_parameters IN CLOB DEFAULT NULL,
idx_duplicate_parameters IN CLOB DEFAULT NULL,
idx_online_build IN BOOLEAN DEFAULT FALSE
);
Parameters
| Parameter | Description |
|---|---|
|
|
Name of the index to create. |
|
|
Table on which to create the index. |
|
|
Vector column on which to create the index. |
idx_include_cols |
A comma-separated list of column names to be covered by the index. |
|
|
Partitioning scheme for IVF indexes:
All IVF indexes are partitioned by centroid. Additionally, IVF indexes support both
global and local indexes on partitioned tables. You can choose
to create a local IVF index, which provides a one-to-one
relationship between the base table partitions or subpartitions
and the index partitions. If the value passed for this parameter
is For detailed information on these partitioning schemes, see Partition Maintenance Operations and Vector indexes. |
|
|
Index organization:
For detailed information on these organization types, see Manage the Different Categories of Vector Indexes. |
|
|
Distance metric or mathematical function used to compute the distance between vectors:
For detailed information on each of these metrics, see Vector Distance Functions and Operators. |
|
|
Target accuracy at which the approximate search should be performed when running an approximate search query. As explained in Understand Approximate Similarity Search Using Vector Indexes, you can specify non-default target accuracy values either by specifying a percentage value or by specifying internal parameters values, depending on the index type you are using.
|
|
|
Type of vector index and associated parameters. Specify the indexing parameters in JSON format:
|
|
|
Parallel degree used for index construction. |
|
|
Optional type of quantization to apply to the indexed vectors. The supported values are |
|
|
Optional compression ratio to use with vector quantization. This is provided either as a numeric value or
|
|
|
Optional JSON object that is used to control distribution for distributed HNSW vector indexes. The value is provided as
This parameter is only supported for HNSW indexes and
can only be used if |
|
|
Optional JSON object that controls duplication for distributed HNSW vector indexes. The value is expected to be either This parameter is only supported for HNSW indexes and
can only be used if |
|
|
Specifies whether the vector index should be built online. The values accepted are |
Examples
-
Specify neighbors and efConstruction for HNSW indexes:
BEGIN DBMS_VECTOR.CREATE_INDEX( idx_name => 'v_hnsw_01', table_name => 'vpt01', idx_vector_col => 'EMBEDDING', idx_include_cols => NULL, idx_partitioning_scheme => NULL, idx_organization => 'INMEMORY NEIGHBOR GRAPH', idx_distance_metric => 'EUCLIDEAN', idx_accuracy => 95, idx_parameters => '{"type" : "HNSW", "neighbors" : 3, "efConstruction" : 4}' ); END; / -
Specify the number of partitions for IVF indexes:
BEGIN DBMS_VECTOR.CREATE_INDEX( idx_name => 'V_IVF_01', table_name => 'vpt01', idx_vector_col => 'EMBEDDING', idx_include_cols => NULL, idx_partitioning_scheme => 'GLOBAL', idx_organization => 'NEIGHBOR PARTITIONS', idx_distance_metric => 'EUCLIDEAN', idx_accuracy => 95, idx_parameters => '{"type" : "IVF", "partitions" : 5, "neighbor partition grouping" : "ON"}', idx_online_build => TRUE ); END; / -
Create a scalar quantized HNSW index:
BEGIN DBMS_VECTOR.CREATE_INDEX( idx_name => 'V_HNSW_SQ_01', table_name => 'VPT01', idx_vector_col => 'EMBEDDING', idx_include_cols => NULL, idx_partitioning_scheme => NULL, idx_organization => 'INMEMORY NEIGHBOR GRAPH', idx_distance_metric => 'EUCLIDEAN', idx_accuracy => 90, idx_quantization_type => 'SCALAR', idx_compression_ratio => 4, idx_parameters => '{ "type" : "HNSW", "neighbors" : 32, "efConstruction" : 200, "rescore factor" : 2, "algorithm" : "uniform_quantization" }' ); END; /
Parent topic: DBMS_VECTOR