Skip to content

Commit

Permalink
Fix for not updating ES mappings when re-indexing
Browse files Browse the repository at this point in the history
  • Loading branch information
wshayes committed Aug 29, 2018
1 parent ea12f4a commit 32c8749
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions bel/resources/namespace.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,14 @@ def load_terms(fo: IO, metadata: dict):
index_name = f"terms_{index_prefix}_{es_version}"

# Create index with mapping
if not elasticsearch.index_exists(es, index_name):
elasticsearch.create_terms_index(es, index_name)
for idx in range(0, 10):
if not elasticsearch.index_exists(es, f'{index_name}_{idx}'):
index_name = f'{index_name}_{idx}'
break

log.info(f'Creating Elasticsearch index {index_name}')

elasticsearch.create_terms_index(es, index_name)

terms_iterator = terms_iterator_for_elasticsearch(fo, index_name)
elasticsearch.bulk_load_docs(es, terms_iterator)
Expand Down

0 comments on commit 32c8749

Please sign in to comment.