Hybrid vector and text query
After the engine index is rebuilt, you can start testing search. OpenSearch Vector Search Edition provides a built-in "Query Test" feature in the console to help you test queries. Three query methods are supported: vector query, primary key query, and hybrid vector and text query. This topic describes the hybrid vector and text query.
Entry point
Click [Query Test] > [Vector Query] and select the table that you want to query. Form mode and developer mode are supported. You can switch between them by using the drop-down list in the upper-right corner. The default mode is form mode:
Select the Hybrid Vector and Text Query tab. In form mode, the following parameters can be configured:
Table Name: Select a table that is in the In Use state.
TopK: The default value is 10.
Filter Condition
Index Name
Namespace
Result Sort Order: Valid values are DESC and ASC.
Dense Vector: The format is
[0.1,0.2,0.3].
Form mode
Form query parameters:
Table Name: Required. The table from which data is retrieved. Select a table in the In Use state of the instance from the drop-down list.
TopK: The maximum number of search results that can be returned. Default value of topK: 10.
Filter Condition: Supported operators are
>, <, =, <=, >=, !=. Multiple conditions can be connected by usingAND, OR, and (). For more information about the syntax, see Filter expressions.Index Name: Required. This parameter is unavailable if no table is selected. After you select a table, the index name is automatically displayed.
Namespace: Optional. You can use namespaces to perform partitioned queries on vector indexes. If no namespace is configured for the instance, you can leave this parameter empty.
Result Sort Order: The default result sort order is
DESC: descending.Dense Vector: Required. The dense vector data to query. Type:
list[float].Sparse Vector Indices: Required. The element indices, which must be sorted in ascending order. Type:
list[int].Sparse Vector Values: Required. The element values, which correspond one-to-one with the indices. Type:
list[float].
Enter the dense and sparse vector values that you want to query and click [Search]. The following results are displayed:
In this example, the table dense_sparse_tb is selected, the filter condition is set to price > 100, the index vector is selected, and the dense vector and sparse vector are entered before Search is clicked. The search results are returned in a table that contains the following columns:
Distance score
Primary key
Dense vector values
Sparse vector indices
Sparse vector values
Attributes (in JSON format, including fields such as content)
Namespace
The results are sorted by distance score in descending order, and the records that meet the filter condition are returned.
Developer mode
Both queries and results are displayed as raw statements. All query features are supported:
{
"tableName": "dense_sparse_tb",
"indexName": "vector",
"vector": [
0.1,
0.2,
0.3,
0.4,
0.5
],
"sparseData": {
"indices": [
0,
2
],
"values": [
1.2,
2.4
]
},
"topK": 2,
"order": "DESC"
}tableName: the table name.
indexName: vector in this example.
vector: the dense vector.
sparseData: the sparse vector.
indices: the sparse vector indices.
values: the sparse vector values.
topK: the number of top results to return.
order: the sort policy. DESC indicates descending order.
For more information about the parameters of hybrid queries, see Sparse vector-based query.