From c0758f0fcd621964df583cb12e7be43ed155f18e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johnny=20Marie=CC=81thoz?= Date: Thu, 23 Jun 2022 14:58:04 +0200 Subject: [PATCH] index: add reindex command MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-by: Johnny MarieĢthoz --- rero_invenio_base/cli/es/index.py | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/rero_invenio_base/cli/es/index.py b/rero_invenio_base/cli/es/index.py index 91ab1c2..2b10b1a 100644 --- a/rero_invenio_base/cli/es/index.py +++ b/rero_invenio_base/cli/es/index.py @@ -30,6 +30,31 @@ def index(): """Elasticsearch index commands.""" +@index.command('reindex') +@with_appcontext +@es_version_check +@click.argument('source') +@click.argument('destination') +def reindex(source, destination): + """Reindex from source. + + See: https://www.elastic.co/guide/en/elasticsearch/reference/7.10/docs-reindex.html # noqa + """ + res = current_search_client.reindex( + body=dict( + source=dict( + index=source + ), + dest=dict( + index=destination, + version_type='external_gte' + ) + ), + wait_for_completion=False + ) + click.secho(f'Task: {res["task"]}', fg='green') + + @index.command('open') @with_appcontext @click.option('-i', '--index', help="default=_all", default='_all') @@ -73,7 +98,7 @@ def switch_index(old, new): click.secho('Sucessfully switched.', fg='green') -@index.command('create_index') +@index.command('create') @with_appcontext @es_version_check @click.option(