remove indexing from ta_config index

This commit is contained in:
Simon
2025-08-11 17:28:25 +07:00
parent a925660078
commit 59331b2b40
2 changed files with 11 additions and 9 deletions

View File

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

View File

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