Query a Vector Search Index
db_vs_indexes_query(
index,
columns,
filters_json,
query_vector = NULL,
query_text = NULL,
score_threshold = 0,
query_type = c("ANN", "HYBRID"),
num_results = 10,
host = db_host(),
token = db_token(),
perform_request = TRUE
)
Name of vector search index
Column names to include in response
JSON string representing query filters, see details.
Numeric vector. Required for direct vector access index and delta sync index using self managed vectors.
Required for delta sync index using model endpoint.
Numeric score threshold for the approximate nearest neighbour (ANN) search. Defaults to 0.0.
One of ANN
(default) or HYBRID
Number of returns to return (default: 10).
Databricks workspace URL, defaults to calling db_host()
.
Databricks workspace token, defaults to calling db_token()
.
If TRUE
(default) the request is performed, if
FALSE
the httr2 request is returned without being performed.
You cannot specify both query_vector
and query_text
at the same time.
filter_jsons
examples:
'{"id <": 5}'
: Filter for id less than 5
'{"id >": 5}'
: Filter for id greater than 5
'{"id <=": 5}'
: Filter for id less than equal to 5
'{"id >=": 5}'
: Filter for id greater than equal to 5
'{"id": 5}'
: Filter for id equal to 5
'{"id": 5, "age >=": 18}'
: Filter for id equal to 5 and age greater than
equal to 18
filter_jsons
will convert attempt to use jsonlite::toJSON
on any
non character vectors.
Refer to docs for Vector Search.
Other Vector Search API:
db_vs_endpoints_create()
,
db_vs_endpoints_delete()
,
db_vs_endpoints_get()
,
db_vs_endpoints_list()
,
db_vs_indexes_create()
,
db_vs_indexes_delete()
,
db_vs_indexes_delete_data()
,
db_vs_indexes_get()
,
db_vs_indexes_list()
,
db_vs_indexes_query_next_page()
,
db_vs_indexes_scan()
,
db_vs_indexes_sync()
,
db_vs_indexes_upsert_data()
,
delta_sync_index_spec()
,
direct_access_index_spec()
,
embedding_source_column()
,
embedding_vector_column()
if (FALSE) {
db_vs_indexes_sync(
index = "myindex",
columns = c("id", "text"),
query_vector = c(1, 2, 3)
)
}
Run the code above in your browser using DataLab