After the reindexing is complete, you can go to the Query Test page in the OpenSearch Vector Search Edition console to run query tests. On the Query Test page, you can perform the following types of queries: vector-based query, primary key-based query, and hybrid query by vector and text. This topic describes how to perform a hybrid query by vector and text.
Procedure
On the details page of your OpenSearch instance, click Query Test in the left-side navigation pane. On the Hybrid Query by Vector and Text tab, select the table whose data you want to query from the Table Name drop-down list. You can select Form Mode or Developer Mode from the drop-down list in the upper-right corner. By default, Form Mode is selected.
Form mode
The following section describes the query parameters:
Table Name: required. The table whose data you want to query. Select a table in the In Use state from the Table Name drop-down list.
TopK: required. The maximum number of query results that can be returned. Default value: 10.
Filter Condition: optional. The filter condition to query data. Supported operators are
>, <, =, <=, >=, and !=
. You can useAND, OR, and ()
to connect multiple conditions. For more information, see Filter expression.Index Name: required. The index name. The parameter is dimmed before you select a table. After you select a table, an index name is automatically specified. You do not need to manually select an index name.
Namespace: optional. The namespace that is used to query data by partition on the vector index. Leave this parameter empty if you do not specify a namespace for the instance.
Result Sort Order: required. The order in which the query results are sorted. Valid values: ASC and DESC. A value of ASC specifies that the query results are sorted in ascending order. A value of DESC specifies that the query results are sorted in descending order. Default value:
DSEC
.Dense Vector: required. The dense vector that you want to query. The value must be in the
list[float]
format.Sparse Vector Subscript: required. The indexes of the sparse vector, which are sorted in ascending order. The value must be in the
list[int]
format.Sparse Vector Value: required. The values of the sparse vector, which correspond to their respective indexes. The value must be in the
list[float]
format.
Enter the dense and sparse vector values that you want to query and click Search.
Developer mode
The query parameters and query results are displayed in the format of original 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 whose data you want to query.
indexName: the index name. In this example, an index named vector is used.
vector: the dense vector.
sparseData: the sparse vector.
indices: the indexes of the sparse vector.
values: the values of the sparse vector.
topK: the maximum number of query results that can be returned.
order: the order in which the query results are sorted. Valid values: ASC and DESC. A value of ASC specifies that the query results are sorted in ascending order. A value of DESC specifies that the query results are sorted in descending order.
For more information, see Hybrid query.