es mapping转dict
def es_mapping2dict(mapping): mapping_dict = dict() if isinstance(mapping, dict): if "properties" in mapping: for k, v in mapping.get("properties").items(): if isinstance(v, dict): if "properties" not in v: if "fields" not in v and "type" in v: field_type = v.get("type") mapping_dict[k] = field_type elif "fields" in v and "type" in v: field_type = v.get("type") mapping_dict[k] = field_type if isinstance(v.get("fields"), dict): for fk, fv in v.get("fields").items(): if "type" in fv: mapping_dict[f"{k}.{fk}"] = fv.get("type") else: mapping_dict[k] = es_mapping2dict(v) return mapping_dict