diff --git a/certego_saas/ext/upload/__init__.py b/certego_saas/ext/upload/__init__.py index 261e576..d0f828d 100644 --- a/certego_saas/ext/upload/__init__.py +++ b/certego_saas/ext/upload/__init__.py @@ -1,3 +1,4 @@ # flake8: noqa +from .elastic import BIDocument, __BIDocumentInterface from .slack import Slack from .twitter import Twitter diff --git a/certego_saas/ext/upload/elastic.py b/certego_saas/ext/upload/elastic.py index f1e3ae8..769d8d0 100644 --- a/certego_saas/ext/upload/elastic.py +++ b/certego_saas/ext/upload/elastic.py @@ -47,13 +47,16 @@ def upload( qs.filter(index=index) docs = qs.order_by("+creation_date") if max_number: + if max_number > 10000: + return False, [ + "max_number can't be higher than 10000 for performance reasons." + ] docs = docs[:max_number] logger.info(f"Uploading {docs.count()} documents") jsons = map(lambda x: x.to_bulk(), docs) success, errors = bulk(client, jsons, request_timeout=timeout) logger.info("Finished Upload. Starting deletion documents") - for doc in docs.iterator(): - doc.delete() + docs.delete() logger.info("Finished deleting documents") return success, errors