0/
⎯⎯ 大气的人,从不为已经不属于自己的东西而惋惜。
--
0 | | 0
说 明
elasticsearch转struct
功能介绍
1.将 mapping
中的 properties
内容转为 struct
2.注意是将 properties
值作为输入内容, 如下:
{
"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"
}
}
}
}
示例
{
"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"
}
}
处理后
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"`
}