【问题标题】:problems with elasticsearch mapping弹性搜索映射问题
【发布时间】:2015-05-19 19:37:30
【问题描述】:

如指南所述, https://www.elastic.co/guide/en/elasticsearch/reference/current/mapping-geo-point-type.html#_mapping_options

我可以使用一个纬度/经度变量数组,并将其映射到 geo_point 类型。

这是我当前的映射:

{
   "zoek": {
      "mappings": {
         "geo": {
            "properties": {
               "country": {
                  "type": "string"
               },
               "geonameid": {
                  "type": "string"
               },
               "locatie": {
                  "type": "double"
               },
               "name": {
                  "type": "string"
               }
            }
         }
      }
   }
}

"locate" 指的是一个由两个 double 组成的数组。 [纬度,经度]。

我想将此映射到 geo_point 变量以执行地理距离查询。

所以我尝试了这个:

PUT /zoek/geo/_mapping 
{
    "geo" : {
        "properties" : {
            "locatie" : {"type" : "geo_point" }
        }
    }
}

得到了这个错误:

{
   "error": "MergeMappingException[Merge failed with failures {[mapper [locatie] of different type, current_type [double], merged_type [geo_point]]}]",

“状态”:400 }

有什么建议吗?

你好,

达格玛。

【问题讨论】:

    标签: elasticsearch


    【解决方案1】:

    在给定的映射类型(即geo)中,您不能定义具有相同名称(即locatie)但类型不同(即一个为double,另一个为geo_point)的两个字段。由于您的 geo 映射类型中已经有一个字段名称 locatie,因此您不能添加一个具有相同名称的新字段,但您绝对可以添加另一个名称不同的字段,例如location_geo.

    但是,我建议更改您的原始映射并将您的locatie(如double)替换为locatie(如geo_point)。但是,如果这样做,您将需要重新索引现有数据,因此这可能不是您的选择。

    【讨论】:

    • curl -XPUT localhost:9200/zoek/geo/0 -d ' { "geonameid" : "2743463", "name" : "Den Oord", "locatie" : [ 51.9708300, 5.2708300], "country" : " NL" } ';
    • 如何更改原始映射?我尝试了this 并得到了类似的错误mapper [source.geoip.coordinates] of different type, current_type [double], merged_type [geo_point]
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2014-08-26
    • 2016-06-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-04-07
    • 1970-01-01
    相关资源
    最近更新 更多