我遇到了failed to find geo_point field [location]
这是我的流程。
导入csv
input {
file {
path => "test.csv"
start_position => "beginning"
sincedb_path => "/dev/null"
}
}
filter {
csv {
separator => ","
#zip,lat, lon
columns => [ "zip" , "lat", "lon"]
}
mutate {
convert => { "zip" => "integer" }
convert => { "lon" => "float" }
convert => { "lat" => "float" }
}
mutate {
rename => {
"lon" => "[location][lon]"
"lat" => "[location][lat]"
}
}
mutate { convert => { "[location]" => "float" } }
}
output {
elasticsearch {
hosts => "cluster:80"
index => "data"
}
stdout {}
}
测试记录
GET data
"hits": [
{
"_index": "data",
"_type": "logs",
"_id": "AVvQcOfXUojnX",
"_score": 1,
"_source": {
"zip": 164283216,
"location": {
"lon": 71.34,
"lat": 40.12
}
}
},
...
如果我尝试运行geo_distance
查询,我会failed to find geo_point field [location]
然后我尝试运行
PUT data
{
"mappings": {
"location": {
"properties": {
"pin": {
"properties": {
"location": {
"type": "geo_point"
}
}
}
}
}
}
}
但我得到index [data/3uxAJ4ISKy_NyVDNC] already exists
如何将location
转换为geo_point
,以便我可以对其进行查询?
编辑:
我在索引任何内容之前尝试种植模板,但仍然存在相同的错误
PUT _template/template
{
"template": "base_map_template",
"order": 1,
"settings": {
"number_of_shards": 1
},
"mappings": {
"node_points": {
"properties": {
"location": {
"type": "geo_point"
}
}
}
}
}
答案 0 :(得分:0)
您需要为模板命名data
而不是base_map_template
,因为这是您的索引的命名方式。类型名称也必须是logs
而不是node_points
:
PUT _template/template
{
"template": "data", <--- change this
"order": 1,
"settings": {
"number_of_shards": 1
},
"mappings": {
"logs": { <--- and this
"properties": {
"location": {
"type": "geo_point"
}
}
}
}
}