我最近使用redis 2.8.24,Elasticsearch 1.2.2和Kibana 3.1升级了我的ELK堆栈(使用redis 3.2.3,Elasticsearch 2.3.5和Kibana 4.5.4的logstash 2.3.4)(logstash 1.4.1/1.4.2) 0.1).升级进行得很顺利,但升级后我有一些字段有冲突类型.此特定字段由logstash动态创建,因此Elasticsearch中没有整体映射.我花了相当多的时间搜索如何改变它.每篇在线文章都说我不能简单地改变现有数据的字段类型.我引用的许多文章都需要重新索引,但未能解释如何.以下是我更改类型和重新索引的确切步骤.
从需要更改字段类型的当前索引获取映射:
curl -XGET http://localhost:9200/logstash-2016.05.30/_mapping?pretty=1 > logstash-2016.05.30
Run Code Online (Sandbox Code Playgroud)
编辑logstash-2016.05.30文件,删除文件中的第二行(索引名称)和第二行(花括号).如果不这样做,将不会更新映射.我想如果你将索引名称编辑为新名称它可以工作,但我没有尝试(应该尝试我猜).
编辑logstash-2016.05.30文件并更改类型(即long为string或string为long).您可以使用类似字段使用的确切定义.
"http_status" : {
"type" : "string",
"norms" : {
"enabled" : false
},
"fields" : {
"raw" : {
"type" : "string",
"index" : "not_analyzed",
"ignore_above" : 256
}
}
},
Run Code Online (Sandbox Code Playgroud)
改成:
"http_status" : {
"type" : "long"
},
Run Code Online (Sandbox Code Playgroud)
接下来创建新索引(追加_new或任何你想要的)
curl -XPUT http://localhost:9200/logstash-2016.05.30_new -d @logstash-2016.05.30
Run Code Online (Sandbox Code Playgroud)
仔细检查映射是否已正确创建
curl -XGET http://localhost:9200/logstash-2016.05.30_new/?pretty
Run Code Online (Sandbox Code Playgroud)
使用以下方法重新索引:
curl -XPOST http://localhost:9200/_reindex -d '{
"source": {
"index" : "logstash-2016.05.30"
},
"dest" …Run Code Online (Sandbox Code Playgroud)