Skip to content

Commit d067606

Browse files
committed
use batches and longer timeout for elastic search
1 parent 49ecf4f commit d067606

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

vector_db/elastic_provider.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ def __init__( # pylint: disable=too-many-arguments,too-many-positional-argument
6767

6868
# We use an incresed timeout since resources are constrained in CI environments
6969
es_params = {
70-
"timeout": 60,
70+
"timeout": 600,
7171
}
7272

7373
self.db = ElasticsearchStore(
@@ -91,4 +91,11 @@ def add_documents(self, docs: List[Document]) -> None:
9191
Args:
9292
docs (List[Document]): List of documents to index.
9393
"""
94-
self.db.add_documents(docs)
94+
batch_size = 50
95+
for i in range(0, len(docs), batch_size):
96+
batch = docs[i : i + batch_size]
97+
try:
98+
self.db.add_documents(batch)
99+
except Exception:
100+
logger.exception("Failed to insert batch starting at index %s", i)
101+
raise

0 commit comments

Comments
 (0)