All Products
Search
Document Center

OpenSearch:Vector-based retrieval syntax

Last Updated:Mar 01, 2025

Syntax for a common query

HA3 syntax

query=index_name:'0.1,0.2,0.98,0.6;0.3,0.4,0.98,0.6...'
Note: The index_name parameter specifies the name of your vector index. Specify the vectors that you want to query after the colon (:).

SQL syntax

query=select proxima_score('index_name') as score,id from table_name where MATCHINDEX('index_name', ?) order by score asc limit 5&&kvpair=timeout:1000,iquan.plan.cache.enable:true;urlencode_data:false;iquan.plan.prepare.level:jni.post.optimize;dynamic_params:[["0.892704,0.783731"]]
Note: The index_name parameter specifies the name of your vector index. The dynamic_params parameter in the kvpair clause specifies the vectors that you want to query.

Syntax for a query for top N vectors

HA3 syntax

query=index_name:'0.1,0.2,0.98,0.6;0.3,0.4,0.98,0.6&n=10'
Note: The index_name parameter specifies the name of your vector index. Specify the vectors that you want to query after the colon (:) and before the ampersand (&). The n parameter specifies the top N vectors that can be returned.

SQL syntax

query=select proxima_score('index_name') as score,id from table_name where MATCHINDEX('index_name', ?) order by score asc limit 5&&kvpair=timeout:1000,iquan.plan.cache.enable:true;urlencode_data:false;iquan.plan.prepare.level:jni.post.optimize;dynamic_params:[["0.892704,0.783731&n=10"]]
Note: The index_name parameter specifies the name of your vector index. The dynamic_params parameter in the kvpair clause specifies the vectors that you want to query. The n parameter specifies the top N vectors that can be returned.

Syntax for a query that includes the specified threshold value

HA3 syntax

query=index_name:'0.1,0.2,0.98,0.6;0.3,0.4,0.98,0.6&n=10&sf=4'
Note: The index_name parameter specifies the name of your vector index. Specify the vectors that you want to query after the colon (:) and before the first ampersand (&). The sf parameter specifies the threshold value based on which the system filters documents. If you set the search_type parameter to ip in the schema.json file, documents whose inner product is less than 4.0 are filtered out. If you set the search_type parameter to l2 in the schema.json file, documents whose Euclidean distance is higher than 2.0 are filtered out. OpenSearch Retrieval Engine Edition uses 2.0 as the threshold value to filter out documents because the square of an Euclidean distance is calculated based on performance.

SQL syntax

query=select proxima_score('index_name') as score,id from table_name where MATCHINDEX('index_name', ?) order by score asc limit 5&&kvpair=timeout:1000,iquan.plan.cache.enable:true;urlencode_data:false;iquan.plan.prepare.level:jni.post.optimize;dynamic_params:[["0.892704,0.783731&n=10&sf=4"]]
Note: The index_name parameter specifies the name of your vector index. The dynamic_params parameter in the kvpair clause specifies the vectors that you want to query. The sf parameter specifies the threshold value based on which the system filters documents. If you set the search_type parameter to ip in the schema.json file, documents whose inner product is less than 4.0 are filtered out. If you set the search_type parameter to l2 in the schema.json file, documents whose Euclidean distance is higher than 2.0 are filtered out. OpenSearch Retrieval Engine Edition uses 2.0 as the threshold value to filter out documents because the square of an Euclidean distance is calculated based on performance.

Syntax for a query based on categories

HA3 syntax

query=aitheta_index_name:'16#0.1,0.2,0.98,0.6;1512#0.3,0.4,0.98,0.6&n=200'
// The search query must be URL-encoded.
query=aitheta_index_name:'16%230.1%2c0.2%2c0.98%2c0.6%3b1512%230.3%2c0.4%2c0.98%2c0.6%26n%3d200'
Note: If you want to query vectors based on categories, you must specify the category IDs and the vectors to be queried. Separate a category ID and a vector with a number sign (#). The number signs in the search query must be URL-encoded. Separate multiple categories with commas (,) and separate multiple vectors with semicolons (;).

SQL syntax

query=select proxima_score('index_name') as score,id from table_name where MATCHINDEX('index_name', ?) order by score asc limit 5&&kvpair=timeout:1000,iquan.plan.cache.enable:true;urlencode_data:false;iquan.plan.prepare.level:jni.post.optimize;dynamic_params:[["16%230.1%2c0.2%2c0.98%2c0.6%3b1512%230.3%2c0.4%2c0.98%2c0.6%26n%3d200"]]
Note: The index_name parameter specifies the name of your vector index. The dynamic_params parameter in the kvpair clause specifies the vectors that you want to query.
Note: The value of the dynamic_params parameter must be URL-encoded.
Note: If you want to query vectors based on categories, you must specify the category IDs and the vectors to be queried. Separate a category ID and a vector with a number sign (#). The number signs in the search query must be URL-encoded. Separate multiple categories with commas (,) and separate multiple vectors with semicolons (;).

Syntax for a query with retrieval parameters

HA3 syntax

query=index_name:'0.1,0.2,0.98,0.6;0.3,0.4,0.98,0.6&n=10&sf=0.8&search_params={"proxima.qc.searcher.scan_ratio":0.001,"proxima.general.searcher.scan_count":10000}'
Note: The search_params parameter specifies the parameters that you want to configure for vector retrieval. The value must be in the JSON format. For more information about the proxima.qc.searcher.scan_ratio parameter, see the "Parameter description" section of the "Vector indexes" topic. The proxima.general.searcher.scan_count parameter is equivalent to the min_scan_doc_cnt parameter.
Note: The order of the n, sf, and search_params parameters cannot be changed.

SQL syntax

query=select proxima_score('index_name') as score,id from table_name where MATCHINDEX('index_name', ?) order by score asc limit 5&&kvpair=timeout:1000,iquan.plan.cache.enable:true;urlencode_data:false;iquan.plan.prepare.level:jni.post.optimize;dynamic_params:[["0.892704,0.783731&n=10&sf=0.8&search_params={"proxima.qc.searcher.scan_ratio":0.001,"proxima.general.searcher.scan_count":10000}"]]

Note: The index_name parameter specifies the name of your vector index. The dynamic_params parameter in the kvpair clause specifies the vectors that you want to query. The search_params parameter specifies the parameters that you want to configure for vector retrieval. The value must be in the JSON format. For more information about the proxima.qc.searcher.scan_ratio parameter, see the "Parameter description" section of the "Vector indexes" topic. The proxima.general.searcher.scan_count parameter is equivalent to the min_scan_doc_cnt parameter.
Note: The order of the n, sf, and search_params parameters cannot be changed.

Syntax for sorting query results based on similarity scores

HA3 syntax

query=index_name:'0.1,0.2,0.98,0.6;0.3,0.4,0.98,0.6...'&&kvpairs=first_formula:proxima_score(index_name)&&sort=+RANK
Note: The index_name parameter specifies the name of your vector index. Specify the vectors that you want to query after the colon (:) and before the first ampersand (&). The kvpairs clause specifies proxima_score(index_name) as the rough sort expression. The sort clause sorts query results in ascending order based on similarity scores.

SQL syntax

query=select proxima_score('index_name') as score,id from table_name where MATCHINDEX('index_name', ?) order by score asc limit 5&&kvpair=timeout:1000,iquan.plan.cache.enable:true;urlencode_data:false;iquan.plan.prepare.level:jni.post.optimize;dynamic_params:[["0.892704,0.783731"]]
Note: The index_name parameter specifies the name of your vector index. The dynamic_params parameter in the kvpair clause specifies the vectors that you want to query. The proxima_score('index_name') function is used to obtain the scores of the vectors. The order by clause specifies that the vectors are sorted based on the scores. asc specifies ascending order. desc specifies descending order.