diff --git a/tubearchivist/home/src/es/index_setup.py b/tubearchivist/home/src/es/index_setup.py index 109b88c..d7e2d03 100644 --- a/tubearchivist/home/src/es/index_setup.py +++ b/tubearchivist/home/src/es/index_setup.py @@ -100,6 +100,7 @@ class ElasticIndex: def rebuild_index(self): """rebuild with new mapping""" + self.create_blank(for_backup=True) self.reindex("backup") self.delete_index(backup=False) self.create_blank() @@ -126,15 +127,19 @@ class ElasticIndex: _, _ = ElasticWrap(path).delete() - def create_blank(self): + def create_blank(self, for_backup=False): """apply new mapping and settings for blank new index""" + path = f"ta_{self.index_name}" + if for_backup: + path = f"{path}_backup" + data = {} if self.expected_set: data.update({"settings": self.expected_set}) if self.expected_map: data.update({"mappings": {"properties": self.expected_map}}) - _, _ = ElasticWrap(f"ta_{self.index_name}").put(data) + _, _ = ElasticWrap(path).put(data) class BackupCallback: