Create a RedisConfig object with a specified metadata schema.
This class method creates a RedisConfig instance using a provided
metadata schema, which defines the structure of additional metadata
fields in the Redis index.
with_metadata_schema(
cls,
metadata_schema: List[Dict[str, Any]],
**kwargs: Any = {}
) -> RedisConfigExample:
from langchain_redis import RedisConfig
metadata_schema = [
{"name": "author", "type": "text"},
{"name": "publication_date", "type": "numeric"},
{"name": "tags", "type": "tag", "separator": ","}
]
config = RedisConfig.with_metadata_schema(
metadata_schema,
index_name="book_index",
redis_url="redis://localhost:6379",
embedding_dimensions=1536
)
print(config.metadata_schema) # Output: The metadata schema list
print(config.index_name) # Output: book_index
Note:
'text', 'numeric', and 'tag'.'tag' fields, you can specify a custom separator using the
'separator' key.RedisVectorStore will create
an index with the specified metadata fields.| Name | Type | Description |
|---|---|---|
metadata_schema* | List[Dict[str, Any]] | A list of dictionaries defining the metadata fields. Each dictionary should contain at least 'name' and 'type' keys. |
**kwargs | Any | Default: {}Additional keyword arguments to configure the Common kwargs include:
|