TairVector is an in-house data structure that provides high-performance real-time storage and retrieval of vectors.
Overview

- HNSW: creates graph-based vector indexes to ensure high search accuracy while maintaining excellent real-time update performance.
- Flat Search: implements exact match and fast data insertion. This algorithm is suitable for small datasets.
- Stores all data in memory and supports real-time index updates to reduce latency of read and write operations.
- Uses an optimized data structure in memory to better utilize storage capacity.
- Functions as an out-of-the-box data structure in a simple and efficient architecture without complex modules or dependencies.
- TairVector was released on October 13, 2022 together with Tair DRAM-based instances that are compatible with Redis 6.0.
- A new version of TairVector that runs the 6.2.2.0 minor version was released on November 22, 2022 to support the Jaccard distance formula. Additionally, the TVS.GETINDEX command supports the
index_data_size
andattribute_data_size
parameters to calculate the memory usage of each vector. - A new version of TairVector that runs the 6.2.3.0 minor version was released on December 26, 2022 to support cluster instances in proxy mode. This new version of TairVector provides the FLOAT16 data type and the , TVS.MINDEXKNNSEARCH, , and TVS.MINDEXMKNNSEARCH commands.
Prerequisites
Precautions
- The TairVector data that you want to manage is stored on the Tair instance.
- The time to live (TTL) feature and the
EXPIRE
andMOVE
commands are unavailable for TairVector.
Supported commands
Type | Command | Syntax | Description |
---|---|---|---|
Vector index operation | TVS.CREATEINDEX | TVS.CREATEINDEX index_name dims algorithm distance_method [algo_param_key alog_param_value] ... | Creates a vector index based on the specified distance function and algorithm. The algorithm is used to create the index and perform queries. The index can be deleted only by running the |
TVS.GETINDEX | TVS.GETINDEX index_name | Queries the specified vector index and retrieves the metadata of the index. | |
TVS.DELINDEX | TVS.DELINDEX index_name | Deletes the specified vector index and all data of the index. | |
TVS.SCANINDEX | TVS.SCANINDEX cursor [MATCH pattern] [COUNT count] | Scans the vector indexes that meet specific criteria in the Tair instance. | |
Vector data operation | TVS.HSET | TVS.HSET index_name key attribute_key attribute_value [attribute_key attribute_value] ... | Inserts a vector into the index. If the vector already exists, the existing data is overwritten. |
TVS.HGETALL | TVS.HGETALL index_name key | Queries all the data records of the specified key in the specified vector index. | |
TVS.HMGET | TVS.HMGET index_name key attribute_key [attribute_key ...] | Queries the value of the attribute_key parameter in the specified key of the specified vector index. | |
TVS.DEL | TVS.DEL index_name key [key ...] | Deletes the specified vectors from the specified vector index by using the key parameter. | |
TVS.HDEL | TVS.HDEL index_name key attribute_key [attribute_key ...] | Deletes the specified attributes of the specified vector from the vector index. | |
TVS.SCAN | TVS.SCAN index_name cursor [MATCH pattern] [COUNT count] | Scans the keys that meet specific criteria in the specified vector index. | |
Vector nearest-neighbor query | TVS.KNNSEARCH | TVS.KNNSEARCH index_name topN vector [filter_string] [param_key param_value] | Queries the nearest-neighbor vectors of the specified vector in the specified vector index. Up to 10,000 vectors can be returned. |
TVS.MKNNSEARCH | TVS.MKNNSEARCH index_name topN vector_count vector [vector ...] [filter_string] [param_key param_value] | Queries the nearest-neighbor vectors of the specified vectors in the specified vector index. | |
TVS.MINDEXKNNSEARCH | TVS.MINDEXKNNSEARCH index_count index_name [index_name ...] topN vector [filter_string] [param_key param_value] | Queries the nearest-neighbor vectors of the specified vector with multiple vector indexes. | |
TVS.MINDEXMKNNSEARCH | TVS.MINDEXMKNNSEARCH index_count index_name [index_name ...] topN vector_count vector [vector ...] [filter_string] [param_key param_value] | Queries the nearest-neighbor vectors of the specified vectors with multiple vector indexes. |
Uppercase keyword
: the command keyword.Italic
: Words in italic indicate variable information that you supply.[options]
: optional parameters. Parameters that are not included in brackets are required.AB
: specifies that these parameters are mutually exclusive. Select one of two or more parameters....
: specifies to repeat the preceding content.
TVS.CREATEINDEX
Item | Description |
---|---|
Syntax | TVS.CREATEINDEX index_name dims algorithm distance_method [algo_param_key alog_param_value] ... |
Time complexity | O(1) |
Command description | Creates a vector index based on the specified distance function and algorithm. The algorithm is used to create the index and perform queries. The index can be deleted only by running the |
Parameter |
|
Output |
|
Example | Sample command:
Sample output:
|
TVS.GETINDEX
Item | Description |
---|---|
Syntax | TVS.GETINDEX index_name |
Time complexity | O(1) |
Command description | Queries the specified vector index and retrieves the metadata of the index. |
Parameter |
|
Output |
|
Example | Run the following commands in advance:
Sample command (with the algorithm parameter set to HNSW):
Sample output:
|
TVS.DELINDEX
Item | Description |
---|---|
Syntax | TVS.DELINDEX index_name |
Time complexity | O(N), in which N indicates the number of keys in the vector index. |
Command description | Deletes the specified vector index and all data of the index. |
Parameter |
|
Output |
|
Example | Sample command:
Sample output:
|
TVS.SCANINDEX
Item | Description |
---|---|
Syntax | TVS.SCANINDEX cursor [MATCH pattern] [COUNT count] |
Time complexity | O(N), in which N indicates the number of vector indexes in the Tair instance. |
Command description | Scans the vector indexes that meet specific criteria in the Tair instance. |
Parameter |
|
Output |
|
Example | Sample command:
Sample output:
|
TVS.HSET
Item | Description |
---|---|
Syntax | TVS.HSET index_name key attribute_key attribute_value [attribute_key attribute_value] ... |
Time complexity | If no indexes are created in this operation, the time complexity is O(1). Otherwise, the time complexity is O(log(N)), in which N indicates the number of keys in the vector index. |
Command description | Inserts a vector into the index. If the vector already exists, the existing data is overwritten. |
Parameter |
|
Output |
|
Example | Sample command:
Sample output:
|
TVS.HGETALL
Item | Description |
---|---|
Syntax | TVS.HGETALL index_name key |
Time complexity | O(1) |
Command description | Queries all the data records of the specified key in the specified vector index. |
Parameter |
|
Output |
|
Example | Sample command:
Sample output:
|
TVS.HMGET
Item | Description |
---|---|
Syntax | TVS.HMGET index_name key attribute_key [attribute_key ...] |
Time complexity | O(1) |
Command description | Queries the value of the attribute_key parameter in the specified key of the specified vector index. |
Parameter |
|
Output |
|
Example | Sample command:
Sample output:
|
TVS.DEL
Item | Description |
---|---|
Syntax | TVS.DEL index_name key [key ...] |
Time complexity | O(1) |
Command description | Deletes the specified vectors from the specified vector index by using the key parameter. |
Parameter |
|
Output |
|
Example | Sample command:
Sample output:
|
TVS.HDEL
Item | Description |
---|---|
Syntax | TVS.HDEL index_name key attribute_key [attribute_key ...] |
Time complexity | O(1) |
Command description | Deletes the specified attributes of the specified vector from the vector index. |
Parameter |
|
Output |
|
Example | Sample command:
Sample output:
|
TVS.SCAN
Item | Description |
---|---|
Syntax | TVS.SCAN index_name cursor [MATCH pattern] [COUNT count] |
Time complexity | O(N), in which N indicates the number of keys in the vector index. |
Command description | Scans the keys that meet specific criteria in the specified vector index. |
Parameter |
|
Output |
|
Example | Sample command:
Sample output:
|
TVS.KNNSEARCH
Item | Description |
---|---|
Syntax | TVS.KNNSEARCH index_name topN vector [filter_string] [param_key param_value] |
Time complexity | O(log(N)), in which N indicates the number of keys in the vector index. |
Command description | Queries the nearest-neighbor vectors of the specified vector in the specified vector index. Up to 10,000 vectors can be returned. |
Parameter |
|
Output |
|
Example | Run the following commands in advance:
Sample command:
Sample output:
|
TVS.MKNNSEARCH
Item | Description |
---|---|
Syntax | TVS.MKNNSEARCH index_name topN vector_count vector [vector ...] [filter_string] [param_key param_value] |
Time complexity | vector_count × O(log(N)), in which N indicates the number of keys in the vector index. |
Command description | Queries the nearest-neighbor vectors of the specified vectors in the specified vector index. |
Parameter |
|
Output |
|
Example | Run the following commands in advance:
Sample command:
Sample output:
|
TVS.MINDEXKNNSEARCH
Item | Description |
---|---|
Syntax | TVS.MINDEXKNNSEARCH index_count index_name [index_name ...] topN vector [filter_string] [param_key param_value] |
Time complexity | index_count × O(log(N)), in which N indicates the number of keys in the vector index. |
Command description | Queries the nearest-neighbor vectors of the specified vector with multiple vector indexes. |
Parameter |
|
Output |
|
Example | Run the following commands in advance:
Sample command:
Sample output:
|
TVS.MINDEXMKNNSEARCH
Item | Description |
---|---|
Syntax | TVS.MINDEXMKNNSEARCH index_count index_name [index_name ...] topN vector_count vector [vector ...] [filter_string] [param_key param_value] |
Time complexity | index_count × O(log(N)), in which N indicates the number of keys in the vector index. |
Command description | Queries the nearest-neighbor vectors of the specified vectors with multiple vector indexes. |
Parameter |
|
Output |
|
Example | Run the following commands in advance:
Sample command:
Sample output:
|