# HG changeset patch # User Adrien Di Mascio <Adrien.DiMascio@logilab.fr> # Date 1500306371 -7200 # Mon Jul 17 17:46:11 2017 +0200 # Node ID 1cfb8bd26fe6c26e97ef6463fae9f5074baddb82 # Parent 56ae3afb23f2f2efee53510a44b2d1552d114b52 [ccplugin] provide a --chunksize option to index-in-es related to #17090555 diff --git a/cubicweb_elasticsearch/ccplugin.py b/cubicweb_elasticsearch/ccplugin.py --- a/cubicweb_elasticsearch/ccplugin.py +++ b/cubicweb_elasticsearch/ccplugin.py @@ -52,6 +52,10 @@ {'type': 'string', 'default': '', 'help': 'all indexable types except given etypes' '[default: []]'}), + ('chunksize', + {'type': 'int', 'default': 100000, + 'help': 'max number of entities to fetch at once (deafult: 100000)', + }), ] def run(self, args): @@ -94,7 +98,9 @@ if index_name is None: index_name = cnx.vreg.config['index-name'] for etype in etypes: - for idx, entity in enumerate(indexable_entities(cnx, etype), 1): + for idx, entity in enumerate( + indexable_entities( + cnx, etype, chunksize=self.config.chunksize), 1): try: serializer = entity.cw_adapt_to('IFullTextIndexSerializable') json = serializer.serialize(complete=False)