我正在学习ElasticSearch并命中一个块。我正在尝试使用logstash将简单的CSV加载到ElasticSearch中。这是数据,它是一个邮编,经度,纬度ElasticSearch 5.0.0 - 关于对象名称的错误已在使用中
ZE1 0BH,-1.136758103355,60.150855671143
ZE1 0NW,-1.15526666950369,60.1532197533966
我使用以下logstash的conf文件过滤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 }
}
而且我已经加入映射使用控制台到ElasticSearch在Kibana
PUT postcodes
{
"settings": {
"number_of_shards": 1
},
"mappings": {
"feature": {
"_all": { "enabled": true },
"properties": {
"postcode": {"type": "text"},
"location": {"type": "geo_point"}
}
}
}
}
我检查mappins使用索引
GET 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瓦片地图可视化数据
任何人都可以解释为什么我收到加载的数据那个错误和我应该使用什么方法?
为什么你有'mutate {convert => {“[location]”=>“float”}}' - 这似乎是你的问题。 – Alcanzar
@Alcanzar我已经删除了,我仍然得到相同的'被定义为一个对象'错误。还有什么我可以尝试吗?谢谢 – tjmgis