Create a RedisConfig object from an IndexSchema.
This class method creates a RedisConfig instance using the provided
IndexSchema, which defines the structure of the Redis index.
from_schema(
cls,
schema: IndexSchema,
**kwargs: Any = {}
) -> RedisConfigExample:
from redisvl.schema import IndexSchema
from langchain_redis import RedisConfig
schema = IndexSchema.from_dict({
"index": {"name": "my_index", "storage_type": "hash"},
"fields": [
{"name": "text", "type": "text"},
{
"name": "embedding",
"type": "vector",
"attrs": {"dims": 1536, "distance_metric": "cosine"}
}
]
})
config = RedisConfig.from_schema(
schema,
redis_url="redis://localhost:6379"
)
print(config.index_name) # Output: my_index
print(config.storage_type) # Output: hash
Note:
RedisVectorStore
matches an existing index structure.| Name | Type | Description |
|---|---|---|
schema* | IndexSchema | An |
**kwargs | Any | Default: {}Additional keyword arguments to override or supplement the schema-derived settings. Common kwargs include:
|