Online Elasticsearch to Go Struct| Generating ES mapping models- GoTool online toolset

开发工具指南

This tool provides a conversion tool from Elasticsearch to Go struct code, which can automatically parse the mapping content of Elasticsearch and convert it to Go struct. The tool supports the injection of multiple tags to ensure that the generated struct code is consistent with the Elasticsearch index structure. The purpose is to simplify the mapping and management of data models, improve development efficiency, and help developers quickly integrate and use Elasticsearch data.

使用说明

feature introduction

  1. Change the contents of properties in mapping to struct, as follows
{
	"mappings": {
		"properties": {
			"doc_id": {
				"type": "keyword"
			},
			"id": {
				"type": "long"
			},
			"path": {
				"type": "keyword"
			},
			"name": {
				"type": "text"
			},
			"url": {
				"type": "keyword"
			},
			"description": {
				"type": "text"
			},
			"created_time": {
				"type": "date",
				"format": "yyyy-MM-dd HH:mm:ss"
			}
		}
	}
}

After treatment

type GenerateObj struct {
    DocId string `json:"doc_id,omitempty"`
    Id int64 `json:"id,omitempty"`
    Path string `json:"path,omitempty"`
    Name string `json:"name,omitempty"`
    Url string `json:"url,omitempty"`
    Description string `json:"description,omitempty"`
    CreatedTime string `json:"created_time,omitempty"`
}