Find answers from the community

Home
Members
robinrump
r
robinrump
Offline, last seen 3 months ago
Joined September 25, 2024
Small question when storing multiple VectorIndecies. I create my indexes like this:

Plain Text
print("Creating index for filter 'procedures'...")
index_procedure = create_index_procedure()
index_procedure.set_index_id('procedure')
index_procedure.storage_context.persist()

print("Creating index for filter 'taxonomy'...")
index_taxonomy = create_index_taxonomy()
index_taxonomy.set_index_id('taxonomy')
index_taxonomy.storage_context.persist()

print("Creating index for filter 'state'...")
index_state = create_index_state()
index_state.set_index_id('state')
index_state.storage_context.persist()


The functions create_index_** all call an internal function that does:

Plain Text
    # Create index
    index = VectorStoreIndex.from_documents(
        documents=documents,
        storage_context=get_storage_context() # common storage context I resuse all over the app
    )


Unfortunately, something seems to be wrong with the indeces, because when I try to load the data as such:

Plain Text
# Get storage context
storage_context = get_storage_context()

# Create indexes
index_procedure = load_index_from_storage(storage_context, 'procedure')
index_taxonomy = load_index_from_storage(storage_context, 'taxonomy')
index_state = load_index_from_storage(storage_context, 'state')


I get the reply ValueError: Failed to load index with ID procedure
1 comment
L
r
robinrump
·

Response

Sorry, I am quite new to this -> I am calling load_index_from_storage(), then on the index as_query_engine() and then I use .query() on the query engine. Is that not right?
7 comments
r
W