From d709b7a3c320cf67a4b1945adb9f218dc005d6c2 Mon Sep 17 00:00:00 2001 From: Murad Khan Date: Thu, 7 Apr 2016 11:51:57 -0400 Subject: [PATCH] Do not try to change the settings for indexes where previousVersion equals 0, it will never exist! --- pydat/scripts/elasticsearch_populate.py | 30 +++++++++++++------------ 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/pydat/scripts/elasticsearch_populate.py b/pydat/scripts/elasticsearch_populate.py index 0d7bccc..52066ca 100755 --- a/pydat/scripts/elasticsearch_populate.py +++ b/pydat/scripts/elasticsearch_populate.py @@ -510,14 +510,15 @@ def unOptimizeIndexes(es, template, options): index_name += "-o" try: - es.indices.put_settings(index="%s-%s-d" % (options.index_prefix, options.previousVersion), - body = {"settings": { - "index": { - "number_of_replicas": template['settings']['number_of_replicas'], - "refresh_interval": template['settings']["refresh_interval"] + if options.previousVersion != 0: + es.indices.put_settings(index="%s-%s-d" % (options.index_prefix, options.previousVersion), + body = {"settings": { + "index": { + "number_of_replicas": template['settings']['number_of_replicas'], + "refresh_interval": template['settings']["refresh_interval"] + } } - } - }) + }) except Exception as e: pass @@ -543,14 +544,15 @@ def optimizeIndexes(es, options): index_name += "-o" try: - es.indices.put_settings(index= "%s-%s-d" % (options.index_prefix, options.previousVersion), - body = {"settings": { - "index": { - "number_of_replicas": 0, - "refresh_interval": "300s" + if options.previousVersion != 0: + es.indices.put_settings(index= "%s-%s-d" % (options.index_prefix, options.previousVersion), + body = {"settings": { + "index": { + "number_of_replicas": 0, + "refresh_interval": "300s" + } } - } - }) + }) except Exception as e: pass