Skip to content

Commit

Permalink
Ignore 400 on index create
Browse files Browse the repository at this point in the history
Close #132
  • Loading branch information
tilgovi committed Feb 1, 2016
1 parent 45267b0 commit fb8003e
Showing 1 changed file with 1 addition and 10 deletions.
11 changes: 1 addition & 10 deletions annotator/elasticsearch.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,16 +89,7 @@ class _Model(dict):
def create_all(cls):
log.info("Creating index '%s'.", cls.es.index)
conn = cls.es.conn
try:
conn.indices.create(cls.es.index)
except elasticsearch.exceptions.RequestError as e:
# Reraise anything that isn't just a notification that the index
# already exists (either as index or as an alias).
if not (e.error.startswith('IndexAlreadyExistsException')
or e.error.startswith('InvalidIndexNameException')):
log.fatal("Failed to create an Elasticsearch index")
raise
log.warn("Index creation failed: index appears to already exist.")
conn.indices.create(cls.es.index, ignore=400)
mapping = cls.get_mapping()
conn.indices.put_mapping(index=cls.es.index,
doc_type=cls.__type__,
Expand Down

0 comments on commit fb8003e

Please sign in to comment.