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.
Example:
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.A list of dictionaries defining the metadata fields. Each dictionary should contain at least 'name' and 'type' keys.
Additional keyword arguments to configure the RedisConfig
instance.
Common kwargs include:
index_name (str): Name of the index in Redis.redis_url (str): URL of the Redis instance.distance_metric (str): Distance metric for vector similarity.embedding_dimensions (int): Dimensionality of embedding vectors.