remove indexing from ta_config index

This commit is contained in:
Simon 2025-08-11 17:28:25 +07:00
parent a925660078
commit 59331b2b40
No known key found for this signature in database
GPG Key ID: 2C15AA5E89985DD4
2 changed files with 11 additions and 9 deletions

View File

@ -1,12 +1,7 @@
{
"index_config": [{
"index_name": "config",
"expected_map": {
"config": {
"type": "object",
"enabled": false
}
},
"expected_map": {},
"expected_set": {
"number_of_replicas": "0"
}

View File

@ -35,7 +35,7 @@ class ElasticIndex:
returns True when rebuild is needed
"""
if self.expected_map:
if self.expected_map or self.expected_map == {}:
rebuild = self.validate_mappings()
if rebuild:
return rebuild
@ -49,7 +49,7 @@ class ElasticIndex:
def validate_mappings(self):
"""check if all mappings are as expected"""
now_map = self.details["mappings"]["properties"]
now_map = self.details["mappings"].get("properties", {})
for key, value in self.expected_map.items():
# nested
@ -75,6 +75,10 @@ class ElasticIndex:
print(f"detected mapping change: {key}, {value}")
return True
# simple doc store
if self.expected_map == {} and now_map != self.expected_map:
return True
return False
def validate_settings(self):
@ -135,8 +139,11 @@ class ElasticIndex:
data = {}
if self.expected_set:
data.update({"settings": self.expected_set})
if self.expected_map:
if self.expected_map or self.expected_map == {}:
data.update({"mappings": {"properties": self.expected_map}})
if self.index_name == "config":
# no indexing for config
data["mappings"]["dynamic"] = False
_, _ = ElasticWrap(path).put(data)