From 59331b2b407f46eaf220e88c245382e462a338ab Mon Sep 17 00:00:00 2001 From: Simon Date: Mon, 11 Aug 2025 17:28:25 +0700 Subject: [PATCH] remove indexing from ta_config index --- backend/appsettings/index_mapping.json | 7 +------ backend/appsettings/src/index_setup.py | 13 ++++++++++--- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/backend/appsettings/index_mapping.json b/backend/appsettings/index_mapping.json index 60c8109e..6c5bff1c 100644 --- a/backend/appsettings/index_mapping.json +++ b/backend/appsettings/index_mapping.json @@ -1,12 +1,7 @@ { "index_config": [{ "index_name": "config", - "expected_map": { - "config": { - "type": "object", - "enabled": false - } - }, + "expected_map": {}, "expected_set": { "number_of_replicas": "0" } diff --git a/backend/appsettings/src/index_setup.py b/backend/appsettings/src/index_setup.py index fc59ddb5..ae1a1438 100644 --- a/backend/appsettings/src/index_setup.py +++ b/backend/appsettings/src/index_setup.py @@ -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)