QUERY
Use the DBMS_VECTOR.QUERY
function to perform a similarity search operation which returns the top-k results as a JSON array.
Syntax
Query is overloaded and supports a version with query_vector
passed
in as a VECTOR
type in addition to CLOB
.
DBMS_VECTOR.QUERY (
TAB_NAME IN VARCHAR2,
VEC_COL_NAME IN VARCHAR2,
QUERY_VECTOR IN CLOB,
TOP_K IN NUMBER,
VEC_PROJ_COLS IN JSON_ARRAY_T DEFAULT NULL,
IDX_NAME IN VARCHAR2 DEFAULT NULL,
DISTANCE_METRIC IN VARCHAR2 DEFAULT 'COSINE',
USE_INDEX IN BOOLEAN DEFAULT TRUE,
ACCURACY IN NUMBER DEFAULT '90',
IDX_PARAMETERS IN CLOB DEFAULT NULL
) return JSON_ARRAY_T;
DBMS_VECTOR.QUERY (
TAB_NAME IN VARCHAR2,
VEC_COL_NAME IN VARCHAR2,
QUERY_VECTOR IN VECTOR,
TOP_K IN NUMBER,
VEC_PROJ_COLS IN JSON_ARRAY_T DEFAULT NULL,
IDX_NAME IN VARCHAR2 DEFAULT NULL,
DISTANCE_METRIC IN VARCHAR2 DEFAULT 'COSINE',
USE_INDEX IN BOOLEAN DEFAULT TRUE,
ACCURACY IN NUMBER DEFAULT '90',
IDX_PARAMETERS IN CLOB DEFAULT NULL
) return JSON_ARRAY_T;
Parameters
Specify the input parameters in JSON format.
Table 12-9 DBMS_VECTOR.QUERY Parameters
Parameter | Description |
---|---|
|
Table name to query |
|
Vector column name |
|
Query vector passed in as |
|
Number of results to be returned. |
|
Columns to be projected as part of the result. |
|
Name of the index queried. |
|
Distance computation metric. Defaults to |
|
Specifies whether the search is an approximate search or exact search. Defaults to TRUE (that is, approximate). |
|
Specifies the minimum desired query accuracy. |
|
Specifies values of |
DATA
This function accepts the input data type as VARCHAR2
,
NUMBER
, JSON
, BOOLEAN
or
CLOB
.
Parent topic: DBMS_VECTOR