db_vs_indexes_query: Query a Vector Search Index

View source: R/vector-search.R

db_vs_indexes_queryR Documentation

Query a Vector Search Index

Description

Query a Vector Search Index

Usage

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
)

Arguments

index

Name of vector search index

columns

Column names to include in response

filters_json

JSON string representing query filters, see details.

query_vector

Numeric vector. Required for direct vector access index and delta sync index using self managed vectors.

query_text

Required for delta sync index using model endpoint.

score_threshold

Numeric score threshold for the approximate nearest neighbour (ANN) search. Defaults to 0.0.

query_type

One of ANN (default) or HYBRID

num_results

Number of returns to return (default: 10).

host

Databricks workspace URL, defaults to calling db_host().

token

Databricks workspace token, defaults to calling db_token().

perform_request

If TRUE (default) the request is performed, if FALSE the httr2 request is returned without being performed.

Details

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.

See Also

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()

Examples

## Not run: 
db_vs_indexes_sync(
  index = "myindex",
  columns = c("id", "text"),
  query_vector = c(1, 2, 3)
)

## End(Not run)


brickster documentation built on April 12, 2025, 1:21 a.m.