New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Question]: How to store two index in redis? #13166
Comments
To store and retrieve your
from llama_index.legacy.vector_stores.redis import RedisVectorStore
redis_vector_store_policy = RedisVectorStore(
index_name="policy_index",
redis_url="redis://localhost:6379/",
overwrite=True
)
redis_vector_store_leave = RedisVectorStore(
index_name="leave_index",
redis_url="redis://localhost:6379/",
overwrite=True,
metadata_fields=["index_leave"]
)
from llama_index.core.schema import BaseNode
class CustomNode(BaseNode):
# Implement necessary methods and properties here
nodes_policy = [CustomNode(index_policy=data) for data in base_nodes+objects]
nodes_leave = [CustomNode(index_leave=data) for data in list_of_documents_leave]
redis_vector_store_policy.add(nodes_policy)
redis_vector_store_leave.add(nodes_leave)
from llama_index.core.vector_stores.types import MetadataFilters, MetadataFilter, VectorStoreQuery
metadata_filters = MetadataFilters(
filters=[
MetadataFilter(key="index_leave", value="desired_leave_value", operator="eq")
]
)
query_embedding = [0.1, 0.2, 0.3] # Use your actual query embedding
query = VectorStoreQuery(query_embedding=query_embedding, filters=metadata_filters, similarity_top_k=10)
result = redis_vector_store_leave.query(query) This approach allows you to persist your indexes in Redis and query them efficiently, including applying filters for exact matches. Make sure to adjust the placeholders and example values to match your actual data and requirements.
|
I got an error
|
@logan-markewich Can you help me for this case? if you want more information don't hesitate ask |
@Ninlawat-Puhu You can use the redis vector store |
Question Validation
Question
I have two index that keep different data as below code
index_policy = VectorStoreIndex(nodes = base_nodes+objects)
index_leave = VectorStoreIndex.from_documents(list_of_documents_leave)
query_engine_leave = index_leave.as_query_engine(similarity_top_k=2,filters = filters,streaming=True)
query_engine_policy = index_policy.as_query_engine(similarity_top_k=6,streaming=True)
But I want to save those index (index_policy,index_leave) in redis database to persist data and I want to call index from redis database instead of local paths. Moreover, with index_leave, I also used ExactMatchFilter for filter information in some columns.
Can you recommend how to develop the code from my requirement?
The text was updated successfully, but these errors were encountered: