首页 文章

ElasticSearch 5.0.0 - 有关对象名称的错误已在使用中

提问于
浏览
0

我正在学习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"}
        }
      }
    }
  }

我使用了检查索引的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 Tile Map来可视化数据

任何人都可以解释为什么我收到该错误以及我应该使用什么方法?

1 回答

  • 0

    您的问题是 elasticsearch 输出上没有 document_type => feature . 如果没有它,它将在类型 logs 上创建对象,这就是你遇到这种冲突的原因 .

相关问题