Find answers from the community

Updated 3 months ago

Indexnode creation and vector store index setup

I create an Indexnode as follows:

Plain Text
indexnode = IndexNode.from_text_node(node, index_id=node.id_)
indexnode.id_ = str(uuid.uuid4())
indexnode.obj = node


Then, I use the following code:

Plain Text
from llama_index.core import StorageContext
storage_context = StorageContext.from_defaults()
index = VectorStoreIndex(
    storage_context=storage_context,
    objects=index_nodes,
)
index.set_index_id("index")
index.storage_context.docstore.add_documents(nodes)
index.storage_context.persist()


However, after running the above code, index.storage_context.docstore.docs['xxxx'].obj is None and cannot be restored by assignment.
This causes my Retriever to be unable to automatically enter into the textNode.
So what is the correct way to save an IndexNode with the obj attribute?
L
Y
2 comments
you can just pass it in like any other node, no need to use objects=

VectorStoreIndex(nodes=<list of index nodes>)

objects is generally there for stuff that isn't serializable
Thanks, I just saw it.
Add a reply
Sign up and join the conversation on Discord