elasticsearch - Elasticsearch映射问题

标签 elasticsearch

如指南所述,
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"
               }
            }
         }
      }
   }
}

“locatie”是指两个double的数组。 [lat,lon]。

我想将此映射到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
}

有什么建议么?

问候,

达格玛

最佳答案

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

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

关于elasticsearch - Elasticsearch映射问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30324440/

相关文章:

c# - 建议完成嵌套的用法

elasticsearch - 带有 Elasticsearch 的 Logstash

azure - 如何连接到Azure上安装的多个节点的elasticsearch集群?如何获取elasticsearch端点?

elasticsearch - 带有数组的Elasticsearch script_score

php - Laravel Elasticsearch 不给出包含或喜欢的匹配

elasticsearch - 如何获取top_hits聚合中的字段

elasticsearch - MongoDB投影附近是否有任何Elasticsearch操作?

linux - 从 bash 脚本启动时 Logstash 关闭停止

java - Java中的ElasticSearch

scala - 如何使用 Spark 中的 elasticsearch-hadoop 将数据从一个 Elasticsearch 集群重新索引到另一个 Elasticsearch 集群