Use commits instead of savepoints to avoid ES timeouts
authorThierry Florac <thierry.florac@onf.fr>
Mon, 19 Nov 2018 11:35:07 +0100
changeset 105 b14588a5bfb1
parent 104 b810c3c52bf2
child 106 99e6eb57ca19
Use commits instead of savepoints to avoid ES timeouts
src/pyams_content_es/site.py
--- a/src/pyams_content_es/site.py	Fri Nov 16 15:42:07 2018 +0100
+++ b/src/pyams_content_es/site.py	Mon Nov 19 11:35:07 2018 +0100
@@ -49,10 +49,11 @@
             set_local_registry(application.getSiteManager())
             indexer = query_utility(IContentIndexerUtility)
             if indexer is not None:
-                for document in find_objects_providing(application, IDocumentIndexTarget):
+                for index, document in enumerate(find_objects_providing(application, IDocumentIndexTarget)):
                     print("Indexing: {0!r}".format(document))
                     es_client.index_object(document)
-                    transaction.savepoint()
+                    if not (index % 10):
+                        transaction.commit()
         finally:
             set_local_registry(None)
         transaction.commit()