JSON 转 ES Mapping 工具 | 在线 JSON 文档转 ES Mapping 生成器 | GoTool在线工具集

高效后端开发工具系列 - 指南与案例

😫 核心痛点

在线 JSON 转 ES Mapping 工具,快速将 Elasticsearch 文档结构转换为 ES Mapping 实体类。支持字段映射、类型自动转换、代码生成,提高开发效率。。在实际开发中,这些琐碎的转换或配置工作往往消耗大量精力且容易引入错误。GoTool 为此提供了快速、准确且免费的在线解决方案。

💡 功能亮点 & 使用方案

功能介绍

1.支持解析嵌套 json 串, 根据递归进行解析嵌套对象
2.支持解析数组 json 串, 会取数组中第一个 json 串进行解析
3.检查 json 串格式是否正确, 输出错误的位置

示例

解析嵌套 json 串

{
	"name": "test",
	"age": 10,
	"addr": "四川成都",
	"cls_info": [
		{
			"name": "篮球班",
			"teacher": "张老师"
		},
		{
			"name": "美术班",
			"teacher": "李老师"
		}
	]
}

处理后

{
  "mappings": {
    "properties": {
      "name": {
        "type": "text",
        "fields": {
          "keyword": {
            "type": "keyword",
            "ignore_above": 256
          }
        }
      },
      "age": {
        "type": "integer"
      },
      "addr": {
        "type": "text",
        "fields": {
          "keyword": {
            "type": "keyword",
            "ignore_above": 256
          }
        }
      },
      "cls_info": {
        "properties": {
          "name": {
            "type": "text",
            "fields": {
              "keyword": {
                "type": "keyword",
                "ignore_above": 256
              }
            }
          },
          "teacher": {
            "type": "text",
            "fields": {
              "keyword": {
                "type": "keyword",
                "ignore_above": 256
              }
            }
          }
        }
      }
    }
  }
}

直接解析数组 json 串

[
	{
		"name": "test",
		"age": 10,
		"addr": "四川成都",
		"cls_info": [
			{
				"name": "篮球班",
				"teacher": "张老师"
			},
			{
				"name": "美术班",
				"teacher": "李老师"
			}
		]
	},
	{
		"name": "test2",
		"age": 10,
		"addr": "四川成都",
		"cls_info": [
			{
				"name": "篮球班",
				"teacher": "张老师"
			},
			{
				"name": "美术班",
				"teacher": "李老师"
			}
		]
	}
]

处理后

{
  "mappings": {
    "properties": {
      "name": {
        "type": "text",
        "fields": {
          "keyword": {
            "type": "keyword",
            "ignore_above": 256
          }
        }
      },
      "age": {
        "type": "integer"
      },
      "addr": {
        "type": "text",
        "fields": {
          "keyword": {
            "type": "keyword",
            "ignore_above": 256
          }
        }
      },
      "cls_info": {
        "properties": {
          "name": {
            "type": "text",
            "fields": {
              "keyword": {
                "type": "keyword",
                "ignore_above": 256
              }
            }
          },
          "teacher": {
            "type": "text",
            "fields": {
              "keyword": {
                "type": "keyword",
                "ignore_above": 256
              }
            }
          }
        }
      }
    }
  }
}