Replies: 1 comment
-
Sure, I can guide you on how to retrieve all nodes from a PGVector database to use them with LlamaIndex classes that expect nodes as input. You can use the Here's a simplified example of how you might use the from llama_index.core.vector_stores.types import VectorStoreQuery
# Assuming `pgvecto_rs_store` is an instance of PGVectoRsStore
# Create a VectorStoreQuery with an empty query_embedding since we want all nodes
# You might need to adjust the parameters according to your specific needs
query = VectorStoreQuery(query_embedding=[], similarity_top_k=100) # Adjust `similarity_top_k` as needed
# Perform the query
result = pgvecto_rs_store.query(query)
# `result.nodes` will contain all the nodes retrieved from the database
nodes = result.nodes In this example, Keep in mind that this approach might need to be adjusted based on the specific requirements of your application, such as filtering specific nodes or handling large datasets efficiently. As for the @dataclass
class VectorStoreQuery:
"""Vector store query."""
query_embedding: Optional[List[float]] = None
similarity_top_k: int = 1
doc_ids: Optional[List[str]] = None
node_ids: Optional[List[str]] = None
query_str: Optional[str] = None
output_fields: Optional[List[str]] = None
embedding_field: Optional[str] = None
mode: VectorStoreQueryMode = VectorStoreQueryMode.DEFAULT
# NOTE: only for hybrid search (0 for bm25, 1 for vector search)
alpha: Optional[float] = None
# metadata filters
filters: Optional[MetadataFilters] = None
# only for mmr
mmr_threshold: Optional[float] = None
# NOTE: currently only used by postgres hybrid search
sparse_top_k: Optional[int] = None
# NOTE: return top k results from hybrid search. similarity_top_k is used for dense search top k
hybrid_top_k: Optional[int] = None You can find more details about these parameters in the source code. I hope this helps! If you have any more questions or need further clarification, feel free to ask. Sources
|
Beta Was this translation helpful? Give feedback.
-
Hi,
Now that I have stored a collection of nodes in a PGVector DB, I'd like to be able to retrieve all the nodes to work on them using LlamaIndex classes that expect nodes as input. How could I do this?
Beta Was this translation helpful? Give feedback.
All reactions