Find answers from the community

Updated 3 months ago

Hi guys, is there anyway to get Node in

Hi guys, is there anyway to get Node in vectorstore or vector index when metadata is known in advance? My case is i have metadata is a link (and it known in advance) and i want get all Node with this metadata (get Node for pass it in my customQueryEngine).

here is example what i want:
Plain Text
# Load the storage context
index = vin_retriever.index
list_link = ['https://www.vinmec.com/vi/tin-tuc/5-dieu-can-biet-ve-viem-phoi-cap-do-virus-corona/','https://www.vinmec.com/vi/tin-tuc/5-dieu-can-biet-ve-viem-phoi-cap-do-virus-corona/']

node_list =[]
# Iterate over all nodes in the storage context
for node in index.vector_store.nodes:
    if node.metadata['url'] in list_link:
        node_list.append(node)


Another way i found is using MetadataFilters but i can't match Filter with multi value with same key (work with 1 filter, not with multi):
Plain Text
filters = MetadataFilters(
    filters=[
        ExactMatchFilter(key="url", value=list_link[1]),
        ExactMatchFilter(key="url", value=list_link[0]),
        ExactMatchFilter(key="url", value=list_link[2]),
        # Add more filters as needed
    ]
)

# Get the retriever with the filters
retriever = index.as_retriever(filters=filters)

Any idea? please
W
J
10 comments
You can access all the nodes using docstore.

nodes = index.docstore.docs
im loading it from vector_store with pg_vector, so it only the vector_store, the docs is empty:
Attachment
image.png
here is way i load it
Wait let me check, if there is any method to access nodes in PGVector
Didn't find any method to fetch nodes in PGVector class
Thank you Fang <3, im also looking the documentation for hours and didn't find any solution. #.# any idea for another approach?
https://github.com/run-llama/llama_index/blob/fcfab6486bc6a0eec31a983dd3056ef9cbe8ceb2/llama_index/vector_stores/postgres.py#L102


Other way would be to create a method which basically query your PGvector table and fetch all the nodes,
Since you already have the client object for the table just need to call it on the DB and fetch it
ahhh got it, lol it ez af, omg what im doing for hours...... Thank Fang ❤️ ❤️ <3333.
Add a reply
Sign up and join the conversation on Discord