# HG changeset patch # User Arthur Lutz <arthur.lutz@logilab.fr> # Date 1481302775 -3600 # Fri Dec 09 17:59:35 2016 +0100 # Node ID 17f8afaefb4e53371a6356c57d50f8c471d04a82 # Parent 7764a7c434dbc6878f3a82f11a8a2b341ac95715 [ccplugin] add index-name option in index-in-es diff --git a/ccplugin.py b/ccplugin.py --- a/ccplugin.py +++ b/ccplugin.py @@ -42,6 +42,9 @@ ('etypes', {'type': 'csv', 'default': '', 'help': 'only index given etypes ' '[default:all indexable types]'}), + ('index-name', {'type': 'string', 'default': '', + 'help': 'override index-name if you want to use a different ID' + '[default: uses index-name from all-in-one.conf]'}), ('except-etypes', {'type': 'string', 'default': '', 'help': 'all indexable types except given etypes' '[default: []]'}), @@ -68,6 +71,7 @@ for _ in parallel_bulk(es, self.bulk_actions(etypes, cnx, + index_name=self.config.index_name, dry_run=self.config.dry_run), raise_on_error=False, raise_on_exception=False): @@ -76,7 +80,8 @@ if self.config.debug: print(u'no elasticsearch configuration found, skipping') - def bulk_actions(self, etypes, cnx, dry_run=False): + def bulk_actions(self, etypes, cnx, + index_name=None, dry_run=False): for etype in etypes: rql = fulltext_indexable_rql(etype, cnx.vreg.schema) rset = cnx.execute(rql) @@ -88,7 +93,7 @@ json = serializer.serialize() if not dry_run: data = {'_op_type': 'index', - '_index': cnx.vreg.config['index-name'], + '_index': index_name or cnx.vreg.config['index-name'], '_type': etype, '_id': entity.eid, '_source': json