From 85a8e2ec2dbe04c0600848953c37bd2179730a1f Mon Sep 17 00:00:00 2001 From: Alisson Date: Mon, 12 Aug 2024 10:06:30 -0300 Subject: [PATCH] fix add documents --- app/store/elasticsearch_vector_store.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/app/store/elasticsearch_vector_store.py b/app/store/elasticsearch_vector_store.py index 113cae6..69304fd 100644 --- a/app/store/elasticsearch_vector_store.py +++ b/app/store/elasticsearch_vector_store.py @@ -62,11 +62,15 @@ def save(self, docs: list[Document]) -> list[str]: index = os.environ.get("INDEX_CONTENTBASES_NAME", "content_bases") if self.vectorstore.client.indices.exists(index=index): - index_documents = self.vectorstore.add_documents - else: - index_documents = self.vectorstore.from_documents - - res = index_documents( + return self.vectorstore.add_documents( + docs, + bulk_kwargs={ + "chunk_size": os.environ.get("CHILD_CHUNK_SIZE", 225), + "max_chunk_bytes": 200000000 + } + ) + + res = self.vectorstore.from_documents( docs, self.vectorstore.embeddings, es_url=os.environ.get("ELASTICSEARCH_URL"),