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

时间:2018-08-27 14:31:19

标签: elasticsearch elastic-stack logstash-configuration

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

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"
      }
    }
  }
}

我收到以下错误:

  

[位置]被定义为映射[doc]中的对象,但是该名称已经用于其他类型的字段中

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

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

我想念什么? 非常感谢。

1 个答案:

答案 0 :(得分:1)

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

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

没有这一行,Logstash使用log类型名称,这就是关闭映射的原因。