我正在学习ElasticSearch并且遇到了障碍。我正在尝试使用logstash将简单的CSV加载到ElasticSearch中。这是数据,它是邮政编码,经度,纬度
ZE1 0BH,-1.136758103355,60.150855671143
ZE1 0NW,-1.15526666950369,60.1532197533966
我使用以下logstash配置文件来过滤CSV以创建“位置”字段
input {
file {
path => "postcodes.csv"
start_position => "beginning"
sincedb_path => "/dev/null"
}
}
filter {
csv {
columns => ["postcode", "lat", "lon"]
separator => ","
}
mutate { convert => {"lat" => "float"} }
mutate { convert => {"lon" => "float"} }
mutate { rename => {"lat" => "[location][lat]"} }
mutate { rename => {"lon" => "[location][lon]"} }
mutate { convert => { "[location]" => "float" } }
}
output {
elasticsearch {
action => "index"
hosts => "localhost"
index => "postcodes"
}
stdout { codec => rubydebug }
}
我已使用Kibana中的控制台将映射添加到ElasticSearch
PUT postcodes
{
"settings": {
"number_of_shards": 1
},
"mappings": {
"feature": {
"_all": { "enabled": true },
"properties": {
"postcode": {"type": "text"},
"location": {"type": "geo_point"}
}
}
}
}
我使用
检查索引的mappinsGET postcodes/_mapping
{
"postcodes": {
"mappings": {
"feature": {
"_all": {
"enabled": true
},
"properties": {
"location": {
"type": "geo_point"
},
"postcode": {
"type": "text"
}
}
}
}
}
}
所以看过文档和发布的其他问题,这一切似乎都是正确的。
然而,当我跑
时bin/logstash -f postcodes.conf
我收到错误:
[location] is defined as an object in mapping [logs] but this name is already used for a field in other types
我尝试过多种替代方法;
删除索引并创建template.json并更改我的conf文件以进行额外设置:
manage_template => true
template => "postcode_template.json"
template_name =>"open_names"
template_overwrite => true
,这会得到同样的错误。
我设法通过不提供模板来加载数据但是数据永远不会作为geo_point加载,因此您无法使用Kibana平铺图来可视化数据
任何人都可以解释我收到错误的原因以及我应该使用哪种方法?
答案 0 :(得分:0)
您的问题是document_type => feature
输出中没有elasticsearch
。如果没有它,它将在类型logs
上创建对象,这就是你遇到这种冲突的原因。