Skip to content

Commit

Permalink
Add a command to reindex an ES index. See #152
Browse files Browse the repository at this point in the history
  • Loading branch information
breyten committed Jan 24, 2024
1 parent a8f31fc commit 9f6a941
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions backend/manage.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
from click.core import Command
from click.decorators import _make_command
from elasticsearch.exceptions import NotFoundError
from elasticsearch.helpers import reindex

from jodal.utils import load_config
from jodal.es import setup_elasticsearch
Expand Down Expand Up @@ -331,6 +332,15 @@ def es_put_template(template_dir):
click.echo("Should make index %s" % (index_name,))
es.indices.create(index=index_name)

@command('reindex')
@click.option('--source', default='jodal_documents', help='Source index')
@click.option('--target', default='jodal_copy_documents', help='Target index')
def es_reindex(source, target):
config = load_config()
es = setup_elasticsearch(config)

click.echo('Copying ES template %s to %s' % (source, target,))
reindex(es, source, target)

@command('run')
@click.option('--host', default='redis', help='Redis host')
Expand All @@ -346,6 +356,7 @@ def worker_run(host, port):
# Register commands explicitly with groups, so we can easily use the docstring
# wrapper
elasticsearch.add_command(es_put_template)
elasticsearch.add_command(es_reindex)

openspending.add_command(openspending_openspendingcompare)

Expand Down

0 comments on commit 9f6a941

Please sign in to comment.