Vector
Redis implementation of vector similarity search capability.
This module provides a Redis implementation of the VectorCapability protocol using RedisVL AsyncSearchIndex for vector storage and similarity search.
RedisVectorCapability(index_name, client, em_invoker, encryption=None, default_batch_size=None)
Bases: BaseVectorCapability
Redis implementation of VectorCapability protocol.
This class provides vector similarity search operations using RedisVL AsyncSearchIndex for vector storage and retrieval.
Attributes:
| Name | Type | Description |
|---|---|---|
index_name |
str
|
Name of the Redis index. |
client |
Redis
|
Redis async client instance. |
em_invoker |
BaseEMInvoker
|
Embedding model for vectorization. |
index |
Any
|
RedisVL AsyncSearchIndex instance. |
Initialize the Redis vector capability.
Schema will be automatically inferred from chunks when creating a new index, or auto-detected from an existing index when performing operations.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
index_name
|
str
|
Name of the Redis index. |
required |
client
|
Redis
|
Redis async client instance. |
required |
em_invoker
|
BaseEMInvoker
|
Embedding model for vectorization. |
required |
encryption
|
EncryptionCapability | None
|
Encryption capability for field-level encryption. Defaults to None. |
None
|
default_batch_size
|
int | None
|
Default batch size for create/update. Defaults to None. |
None
|
ensure_index(filterable_fields=None, **kwargs)
async
Ensure Redis vector index exists, creating it if necessary.
This method is idempotent - if the index already exists, it will skip creation and return early.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
filterable_fields
|
list[dict[str, Any]] | None
|
List of filterable field configurations to use when creating a new index. Each field should be a dictionary with "name" and "type" keys. For example: [{"name": "metadata.category", "type": "tag"}, {"name": "metadata.score", "type": "numeric"}] If not provided and index doesn't exist, a default schema will be created with only basic fields (id, content, metadata, vector). Defaults to None. |
None
|
**kwargs
|
Any
|
Additional keyword arguments (e.g. from base capability interface); Unused in this implementation. |
{}
|
Raises:
| Type | Description |
|---|---|
RuntimeError
|
If index creation fails. |