将经度和纬度从 .csv 数据映射到 geo_point 类型不起作用

Mapping longitude and latitude from .csv data to geo_point type not working

这是我第四次尝试做这些映射。但是我没有以前的配置文件。

classes2.conf

    input {
  file {

    path => "D:\Workspace.Elastic\FinalVersions\classes.csv"    
    start_position => "beginning"
    sincedb_path => "/dev/null"
  }
}

filter {

    csv {
        columns => ["TITLE","PROFFESSOR","MAJOR","SEMESTER","student_count","unit","rating","submit_date","latitude","longitude"]
        separator => ","


    }   

    mutate {
        convert => { "longitude" => "float" }
        convert => { "latitude" => "float" }
        rename => {
            "longitude" => "[location][lon]"
            "latitude" => "[location][lat]"
        }
    }
}

output {
    stdout { codec => rubydebug }
    elasticsearch {
        hosts => "localhost:9200"
        index => "geopointest"
    }
}

classesRating_mapping2.json

{
  "class": {
    "properties": {

      "location": {
        "type": "geo_point"
      }
    }
  }
}

我收到以下错误:

[location] is defined as an object in mapping [doc] but this name is already used for a field in other types"

我已经创建了 geopointest 索引并添加了 json 映射,如下所示:

curl  -X PUT -H "Content-Type: application/json" http://localhost:9200/geopointest/class/_mapping --data-binary @classesRating_mapping2.json

我错过了什么? 非常感谢。

问题在于您在映射中使用的是自定义类型名称 class。这意味着您需要像这样修改 elasticsearch 输出:

elasticsearch {
    hosts => "localhost:9200"
    index => "geopointest"
    document_type => "class"        <-- add this line
}

如果没有该行,Logstash 将使用 log 类型名称,这就是您的映射被关闭的原因。