fd dg
public Map<String, Map<String, String>> javaBeanToMapping(Object instance, List<String> textMappingList, Map<String, String> nestedMappingMap) { Field field; Map<String, Map<String, String>> fieldMaps = new HashMap<>(); Class information = instance.getClass(); Field[] fields = information.getDeclaredFields(); for (int i = 0; i < fields.length; i++) { field = fields[i]; Map<String, String> fieldMap = new HashMap<>(); if (CommonFuctions.isNotEmptyList(textMappingList) && textMappingList.contains(field.getName())) { fieldMap.put("type", "text"); fieldMap.put("analyzer", EsConstant.ES_ANALYSIS_IK); fieldMap.put("search_analyzer", EsConstant.ES_ANALYSIS_IK_SMART); fieldMaps.put(field.getName(), fieldMap); } else if (nestedMappingMap != null && nestedMappingMap.containsKey(field.getName())) { fieldMap.put("type", "nested"); fieldMap.put(EsConstant.ES_NESTED_PROPERTIES, nestedMappingMap.get(field.getName())); fieldMaps.put(field.getName(), fieldMap); } else if ("class java.lang.String".equals(field.getType())) { fieldMap.put("type", "keyword"); fieldMaps.put(field.getName(), fieldMap); } else if ("class java.lang.Integer".equals(field.getType().toString())) { fieldMap.put("type", "integer"); fieldMaps.put(field.getName(), fieldMap); } else if ("class java.lang.Float".equals(field.getType().toString())) { fieldMap.put("type", "float"); fieldMaps.put(field.getName(), fieldMap); } else if ("class java.lang.Double".equals(field.getType().toString())) { fieldMap.put("type", "double"); fieldMaps.put(field.getName(), fieldMap); } else if ("class java.util.Date".equals(field.getType().toString())) { fieldMap.put("type", "date"); fieldMap.put("format", "yyyy-MM-dd HH:mm:ss||yyyy-MM-dd'T'HH:mm:ss||epoch_millis"); fieldMaps.put(field.getName(), fieldMap); } else if (field.getType().toString().contains("[")) { fieldMap.put("type", "array"); fieldMaps.put(field.getName(), fieldMap); } else if ("interface java.util.List".equals(field.getType().toString())) { fieldMap.put("type", "keyword"); fieldMaps.put(field.getName(), fieldMap); } else { fieldMap.put("type", "keyword"); fieldMaps.put(field.getName(), fieldMap); } } return fieldMaps; }