elasticsearch创建索引映射 - Go语言中文社区

elasticsearch创建索引映射


1.我们这里通过google自带的工具postman来创建索引,这里我们创建一个:vclogdb,看到返回"acknowledged": true,表示创建成功;


2.通过elasticsearch-head工具可以查看到刚刚创建的vclogdb索引;


3.在已创建索引的情况下,创建类型映射,这里类型为:recordoriginaldata,创建语句:

{
	"recordoriginaldata": {
		"properties": {
			"duration": {
				"type": "long"
			},
			"extension": {
				"type": "text",
				"fields": {
					"keyword": {
						"ignore_above": 256,
						"type": "keyword"
					}
				}
			},
			"calledid": {
				"type": "text",
				"fields": {
					"keyword": {
						"ignore_above": 256,
						"type": "keyword"
					}
				}
			},
			"fragments": {
				"properties": {
					"from": {
						"type": "text",
						"fields": {
							"keyword": {
								"ignore_above": 256,
								"type": "keyword"
							}
						}
					},
					"text": {
						"type": "text",
						"fields": {
							"keyword": {
								"ignore_above": 256,
								"type": "keyword"
							}
						}
					},
					"begin": {
						"type": "text",
						"fields": {
							"keyword": {
								"ignore_above": 256,
								"type": "keyword"
							}
						}
					}
				}
			},
			"callerid": {
				"type": "text",
				"fields": {
					"keyword": {
						"ignore_above": 256,
						"type": "keyword"
					}
				}
			},
			"startrecordtime": {
				"type": "date",
				"format": "yyyy-MM-dd HH:mm:ss||yyyy-MM-dd||epoch_millis"
			}
		}
	}
}


3.在没有创建索引的情况下,创建索引类型映射,这里索引为:vclogdb,类型为:recordoriginaldata,创建语句:

{
	"mappings": {
		"recordoriginaldata": {
			"properties": {
				"duration": {
					"type": "long"
				},
				"extension": {
					"type": "text",
					"fields": {
						"keyword": {
							"ignore_above": 256,
							"type": "keyword"
						}
					}
				},
				"calledid": {
					"type": "text",
					"fields": {
						"keyword": {
							"ignore_above": 256,
							"type": "keyword"
						}
					}
				},
				"fragments": {
					"properties": {
						"from": {
							"type": "text",
							"fields": {
								"keyword": {
									"ignore_above": 256,
									"type": "keyword"
								}
							}
						},
						"text": {
							"type": "text",
							"fields": {
								"keyword": {
									"ignore_above": 256,
									"type": "keyword"
								}
							}
						},
						"begin": {
							"type": "text",
							"fields": {
								"keyword": {
									"ignore_above": 256,
									"type": "keyword"
								}
							}
						}
					}
				},
				"callerid": {
					"type": "text",
					"fields": {
						"keyword": {
							"ignore_above": 256,
							"type": "keyword"
						}
					}
				},
				"startrecordtime": {
					"type": "date",
					"format": "yyyy-MM-dd HH:mm:ss||yyyy-MM-dd||epoch_millis"
				}
			}
		}
	}
}


5.删除索引;


版权声明:本文来源CSDN,感谢博主原创文章,遵循 CC 4.0 by-sa 版权协议,转载请附上原文出处链接和本声明。
原文链接:https://blog.csdn.net/Damon_01/article/details/80448869
站方申明:本站部分内容来自社区用户分享,若涉及侵权,请联系站方删除。
  • 发表于 2020-03-07 18:47:59
  • 阅读 ( 1608 )
  • 分类:

0 条评论

请先 登录 后评论

官方社群

GO教程

猜你喜欢