Fix DataInsights Field Getter (#17427)

This commit is contained in:
IceS2 2024-08-13 18:28:33 +02:00 committed by GitHub
parent 2dfd7d1f70
commit c221f80d15
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 18 additions and 16 deletions

View File

@ -2010,6 +2010,7 @@ public class ElasticSearchClient implements SearchClient {
@Override
public List<Map<String, String>> fetchDIChartFields() throws IOException {
List<Map<String, String>> fields = new ArrayList<>();
GetMappingsRequest request =
new GetMappingsRequest().indices(DataInsightSystemChartRepository.DI_SEARCH_INDEX);
@ -2020,11 +2021,9 @@ public class ElasticSearchClient implements SearchClient {
for (Map.Entry<String, MappingMetadata> entry : response.mappings().entrySet()) {
// Get fields for the index
Map<String, Object> indexFields = entry.getValue().sourceAsMap();
List<Map<String, String>> fields = new ArrayList<>();
getFieldNames((Map<String, Object>) indexFields.get("properties"), "", fields);
return fields;
}
return null;
return fields;
}
void getFieldNames(
@ -2045,11 +2044,13 @@ public class ElasticSearchClient implements SearchClient {
getFieldNames(
(Map<String, Object>) subFields.get("properties"), fieldName + ".", fieldList);
} else {
Map<String, String> map = new HashMap<>();
map.put("name", fieldName);
map.put("displayName", fieldNameOriginal);
map.put("type", type);
fieldList.add(map);
if (fieldList.stream().noneMatch(e -> e.get("name").equals(fieldName))) {
Map<String, String> map = new HashMap<>();
map.put("name", fieldName);
map.put("displayName", fieldNameOriginal);
map.put("type", type);
fieldList.add(map);
}
}
}
}

View File

@ -1987,6 +1987,7 @@ public class OpenSearchClient implements SearchClient {
@Override
public List<Map<String, String>> fetchDIChartFields() throws IOException {
List<Map<String, String>> fields = new ArrayList<>();
GetMappingsRequest request =
new GetMappingsRequest().indices(DataInsightSystemChartRepository.DI_SEARCH_INDEX);
@ -1997,11 +1998,9 @@ public class OpenSearchClient implements SearchClient {
for (Map.Entry<String, MappingMetadata> entry : response.mappings().entrySet()) {
// Get fields for the index
Map<String, Object> indexFields = entry.getValue().sourceAsMap();
List<Map<String, String>> fields = new ArrayList<>();
getFieldNames((Map<String, Object>) indexFields.get("properties"), "", fields);
return fields;
}
return null;
return fields;
}
void getFieldNames(
@ -2022,11 +2021,13 @@ public class OpenSearchClient implements SearchClient {
getFieldNames(
(Map<String, Object>) subFields.get("properties"), fieldName + ".", fieldList);
} else {
Map<String, String> map = new HashMap<>();
map.put("name", fieldName);
map.put("displayName", fieldNameOriginal);
map.put("type", type);
fieldList.add(map);
if (fieldList.stream().noneMatch(e -> e.get("name").equals(fieldName))) {
Map<String, String> map = new HashMap<>();
map.put("name", fieldName);
map.put("displayName", fieldNameOriginal);
map.put("type", type);
fieldList.add(map);
}
}
}
}