Hi all.
I have an api endpoint that does the following:
...
parser = SimpleNodeParser()
nodes = parser.get_nodes_from_documents(documents)
# create (or load) docstore and add nodes
docstore = MongoDocumentStore.from_uri(uri=URI, db_name='db', namespace='public')
docstore.add_documents(nodes)
# create storage context
storage_context = StorageContext.from_defaults(
docstore=docstore,
index_store=MongoIndexStore.from_uri(uri=URI, db_name='db', namespace='public')
)
# build index
index = GPTVectorStoreIndex(nodes, storage_context=storage_context)
On a separate endpoint, I wanna load the index and query it:
storage_context = StorageContext.from_defaults(
docstore=MongoDocumentStore.from_uri(uri=URI, db_name='db', namespace='public'),
index_store=MongoIndexStore.from_uri(uri=URI, db_name='db', namespace='public')
)
index = load_index_from_storage(storage_context)
query_engine = index.as_query_engine()
result = query_engine.query(data.prompt)
this errors out with
KeyError('1')
.
I believe that stems from a method on the storage context that
load_index_from_storage
calls deep in the code:
storage_context.index_store.index_structs()
.
This is what errors out with
KeyError('1')
; I take it that means it couldn't find an index/index_struct? But
https://gpt-index.readthedocs.io/en/latest/how_to/storage/index_stores.html says that, if using MongoDBIndexStore, you don't have to persist storage.
am I loading the index correctly? Am I fundamentally doing something wrong?