Skip to content
This repository has been archived by the owner on Apr 11, 2024. It is now read-only.

Commit

Permalink
[Index Configuration Tool] Remove filtering of "strict" mapping
Browse files Browse the repository at this point in the history
opensearch-project/data-prepper#2864 has been fixed so that "index" and "document_id" fields are no longer injected into the resulting document that is pushed to the target cluster. Thus, we can remove this workaround and revert to enforcing "strict" mappings for indices that are configured as such.

Signed-off-by: Kartik Ganesh <[email protected]>
  • Loading branch information
kartg committed Jul 19, 2023
1 parent a7b7bcd commit 2dacace
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 17 deletions.
11 changes: 0 additions & 11 deletions index_configuration_tool/index_operations.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@
__INDEX_KEY = "index"
__ALL_INDICES_ENDPOINT = "*"
__INTERNAL_SETTINGS_KEYS = ["creation_date", "uuid", "provided_name", "version", "store"]
__DYNAMIC_KEY = "dynamic"
__STRICT_VALUE = "strict"


def fetch_all_indices(endpoint: str, optional_auth: Optional[tuple] = None, verify: bool = True) -> dict:
Expand All @@ -19,15 +17,6 @@ def fetch_all_indices(endpoint: str, optional_auth: Optional[tuple] = None, veri
# Remove internal settings
result = dict(resp.json())
for index in result:
# TODO Remove after https://github.com/opensearch-project/data-prepper/issues/2864 is resolved
try:
dynamic_mapping_value = result[index][MAPPINGS_KEY][__DYNAMIC_KEY]
if dynamic_mapping_value == __STRICT_VALUE:
del result[index][MAPPINGS_KEY][__DYNAMIC_KEY]
except KeyError:
# One of the keys in the path above is not present, so we can
# ignore the deletion logic and execute the rest
pass
for setting in __INTERNAL_SETTINGS_KEYS:
index_settings = result[index][SETTINGS_KEY]
if __INDEX_KEY in index_settings:
Expand Down
2 changes: 0 additions & 2 deletions index_configuration_tool/tests/test_constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@
}
},
MAPPINGS_KEY: {
# Strict mapping should be filtered out
"dynamic": "strict"
}
},
Expand All @@ -50,7 +49,6 @@
}
},
MAPPINGS_KEY: {
"dynamic": "false",
"id": {"type": "keyword"}
}
}
Expand Down
5 changes: 1 addition & 4 deletions index_configuration_tool/tests/test_index_operations.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,8 @@ def test_fetch_all_indices(self):
index_settings = index_data[test_constants.INDEX1_NAME][test_constants.SETTINGS_KEY]
self.assertTrue(test_constants.INDEX_KEY in index_settings)
self.assertEqual({"is_filtered": False}, index_settings[test_constants.INDEX_KEY])
# Test that only strict mapping is filtered out
index_mappings = index_data[test_constants.INDEX2_NAME][test_constants.MAPPINGS_KEY]
self.assertEqual(0, len(index_mappings))
index_mappings = index_data[test_constants.INDEX3_NAME][test_constants.MAPPINGS_KEY]
self.assertEqual("false", index_mappings["dynamic"])
self.assertEqual("strict", index_mappings["dynamic"])

@responses.activate
def test_create_indices(self):
Expand Down

0 comments on commit 2dacace

Please sign in to comment.