storage_context = StorageContext.from_defaults() index1 = VectorStoreIndex.from_documents(..., storage_context=storage_context) index2 = VectorStoreIndex.from_documents(..., storage_context=storage_context)
index1 = VectorStoreIndex.from_documents(documents1, service_context=service_context)
index1.set_index_id(index_name1)
index1.storage_context.persist(persist_dir=persist_dir)
index2 = VectorStoreIndex.from_documents(documents2, service_context=service_context)
index2.set_index_id(index_name2)
index2.storage_context.persist(persist_dir=persist_dir)
from llama_index import StorageContext storage_context = StorageContext.from_defaults() index1 = VectorStoreIndex.from_documents(documents1, service_context=service_context, storage_context=storage_context) index1.set_index_id(index_name1) index1.storage_context.persist(persist_dir=persist_dir) index2 = VectorStoreIndex.from_documents(documents2, service_context=service_context, storage_context=storage_context) index2.set_index_id(index_name2) index2.storage_context.persist(persist_dir=persist_dir)