Skip to content
Snippets Groups Projects
Commit 17f8afaefb4e authored by Arthur Lutz's avatar Arthur Lutz
Browse files

[ccplugin] add index-name option in index-in-es

parent 7764a7c434db
No related branches found
No related tags found
No related merge requests found
......@@ -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
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment