def load_terms(fo: IO, metadata: dict, forceupdate: bool):
version = metadata["<STR_LIT>"]["<STR_LIT:version>"]<EOL>with timy.Timer("<STR_LIT>") as timer:<EOL><INDENT>es = bel.db.elasticsearch.get_client()<EOL>es_version = version.replace("<STR_LIT:T>", "<STR_LIT>").replace("<STR_LIT:->", "<STR_LIT>").replace("<STR_LIT::>", "<STR_LIT>")<EOL>index_prefix = f"<STR_LIT>"<EOL>index_name = f"<STR_LIT>"<EOL>if not elasticsearch.index_exists(es, index_name):<EOL><INDENT>elasticsearch.create_terms_index(es, index_name)<EOL><DEDENT>elif forceupdate:  <EOL><INDENT>index_name += "<STR_LIT>"<EOL>elasticsearch.create_terms_index(es, index_name)<EOL><DEDENT>else:<EOL><INDENT>return  <EOL><DEDENT>terms_iterator = terms_iterator_for_elasticsearch(fo, index_name)<EOL>elasticsearch.bulk_load_docs(es, terms_iterator)<EOL>index_names = elasticsearch.get_all_index_names(es)<EOL>for name in index_names:<EOL><INDENT>if name != index_name and index_prefix in name:<EOL><INDENT>elasticsearch.delete_index(es, name)<EOL><DEDENT><DEDENT>elasticsearch.add_index_alias(es, index_name, terms_alias)<EOL>log.info(<EOL>"<STR_LIT>",<EOL>elapsed=timer.elapsed,<EOL>namespace=metadata["<STR_LIT>"]["<STR_LIT>"],<EOL>)<EOL><DEDENT>with timy.Timer("<STR_LIT>") as timer:<EOL><INDENT>arango_client = arangodb.get_client()<EOL>belns_db = arangodb.get_belns_handle(arango_client)<EOL>arangodb.batch_load_docs(<EOL>belns_db, terms_iterator_for_arangodb(fo, version), on_duplicate="<STR_LIT>"<EOL>)<EOL>log.info(<EOL>"<STR_LIT>",<EOL>elapsed=timer.elapsed,<EOL>namespace=metadata["<STR_LIT>"]["<STR_LIT>"],<EOL>)<EOL>remove_old_equivalence_edges = f"""<STR_LIT>"""<EOL>remove_old_equivalence_nodes = f"""<STR_LIT>"""<EOL>arangodb.aql_query(belns_db, remove_old_equivalence_edges)<EOL>arangodb.aql_query(belns_db, remove_old_equivalence_nodes)<EOL><DEDENT>metadata["<STR_LIT>"] = f"<STR_LIT>"<EOL>try:<EOL><INDENT>belns_db.collection(arangodb.belns_metadata_name).insert(metadata)<EOL><DEDENT>except ArangoError as ae:<EOL><INDENT>belns_db.collection(arangodb.belns_metadata_name).replace(metadata)<EOL><DEDENT>
Load terms into Elasticsearch and ArangoDB

    Forceupdate will create a new index in Elasticsearch regardless of whether
    an index with the resource version already exists.

    Args:
        fo: file obj - terminology file
        metadata: dict containing the metadata for terminology
        forceupdate: force full update - e.g. don't leave Elasticsearch indexes
            alone if their version ID matches