Commit df302c8e authored by Alessandro CERIONI's avatar Alessandro CERIONI
Browse files

Minor improvement and bugfix

* we check whether an index already exists before attempting the index creation
* aliases are set even in case of incremental update
parent 9da7c060
Pipeline #4226 passed with stages
in 2 minutes and 13 seconds
......@@ -62,20 +62,18 @@ def index_docs( cfg, content_type, docs ):
}
}
try:
# create index, in case it doesn't exist yet
if not es.indices.exists(index=es_index):
rep = es.indices.create(es_index, es_body)
except Exception as e:
print(e)
logger.info(f'Index "{es_index}" created.')
logger.info("Pushing %i documents into Elasticsearch..." % len(docs))
header = {
"index" : {
"_index" : es_index,
"_type" : "_doc"
}
}
"index" : {
"_index" : es_index,
"_type" : "_doc"
}
}
es_body = ''
......
......@@ -36,12 +36,9 @@ def reindexer(cfg, content_type, content_id=None):
rep = destin_es.indices.put_template(cfg['reindexer']['template'][content_type], template)
try:
rep = destin_es.indices.create(cfg['reindexer']['destination_index'][content_type])
#print(rep)
except Exception as e:
logger.error(e)
pass
if not destin_es.indices.exists(index=destin_index):
rep = destin_es.indices.create(destin_index)
logger.info(f'Index "{destin_index}" created.')
body = {
# "conflicts": "proceed",
......
......@@ -82,6 +82,9 @@ def add_content( cfg, content_type, data ):
raise Exception('Something went wrong. Exiting...')
exit(1)
logging.info('Setting aliases...')
successful = alias_setter(cfg, content_type)
logging.info('done.')
return task_url
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment