def reindex(args):
    request = bootstrap(args)

    # Configure the new index
    search_config.configure_index(request.legacy_es, args.target)

    # Reindex the annotations
    es_helpers.reindex(client=request.legacy_es.conn,
                       source_index=request.legacy_es.index,
                       target_index=args.target)

    if args.update_alias:
        request.legacy_es.conn.indices.update_aliases(body={'actions': [
            # Remove all existing aliases
            {"remove": {"index": "*", "alias": request.legacy_es.index}},
            # Alias current index name to new target
            {"add": {"index": args.target, "alias": request.legacy_es.index}},
        ]})
Reindex the annotations into a new Elasticsearch index.
dataset/ETHPy150Open hypothesis/h/h/script.py/reindex