Skip to content

Commit

Permalink
check if index exists
Browse files Browse the repository at this point in the history
  • Loading branch information
AlisoSouza committed Aug 12, 2024
1 parent 4fdacf2 commit d2f39cb
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion app/store/elasticsearch_vector_store.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,13 @@ class ContentBaseElasticsearchVectorStoreIndex(ElasticsearchVectorStoreIndex):

def save(self, docs: list[Document]) -> list[str]:
index = os.environ.get("INDEX_CONTENTBASES_NAME", "content_bases")
res = self.vectorstore.from_documents(

if self.vectorstore.client.indices.exists(index=index):
index_documents = self.vectorstore.add_documents
else:
index_documents = self.vectorstore.from_documents

res = index_documents(
docs,
self.vectorstore.embeddings,
es_url=os.environ.get("ELASTICSEARCH_URL"),
Expand Down

0 comments on commit d2f39cb

Please sign in to comment.