Replies: 1 comment
-
To retrieve the whole document from a chunked node when using Redis vector store, you can use the from llama_index.vector_stores.redis import RedisVectorStore
from llama_index.vector_stores.types import VectorStoreQuery
# Initialize the RedisVectorStore
vector_store = RedisVectorStore(
index_name="my_index",
redis_url="redis://localhost:6379/"
)
# Create a query object
query = VectorStoreQuery(
query_embedding=[0.1, 0.2, 0.3], # Example embedding
similarity_top_k=10
)
# Query the index
result = vector_store.query(query)
# Retrieve and print the whole document
for node in result.nodes:
print(node.text) This code will query the Redis vector store for the top 10 most similar nodes based on the provided embedding and print out the text content of each node. By iterating through the nodes, you can piece together the whole document. Additionally, you can use the from llama_index.core import StorageContext, VectorStoreIndex
from llama_index.core.llms import MockLLM
from llama_index.vector_stores.redis import RedisVectorStore
# Initialize the RedisVectorStore
vector_store = RedisVectorStore(redis_url="redis://localhost:6379/")
storage_context = StorageContext.from_defaults(vector_store=vector_store)
index = VectorStoreIndex.from_documents(
documents, # Your list of documents
embed_model=MockEmbedding(embed_dim=1536),
storage_context=storage_context,
)
# Create a query engine
query_engine = index.as_query_engine(llm=MockLLM(), similarity_top_k=10)
# Query the index
query_res = query_engine.query("Your query here")
# Retrieve and print the whole document
for node in query_res.source_nodes:
print(node.text) This approach uses the |
Beta Was this translation helpful? Give feedback.
-
How to retrieve the whole document from a chunked node when using redis vector store
Beta Was this translation helpful? Give feedback.
All reactions