Elasticsearch 7.10.1加载数据时出现非法参数异常

Illegal Argument Exception in Elasticsearch 7.10.1 when Loading data

当我尝试将数据加载到我使用映射创建的索引时出现错误。这是我所做的:

我已经使用以下命令创建了一个映射到 ElasticSearch(版本 7.10.1)运行 的索引 docker 容器:

curl -sS -H "Content-Type: application/json" -XPUT localhost:9200/test_write_v1?pretty -d {
    "settings" : {
        "index" : {
            "number_of_shards" : 1, 
            "number_of_replicas" : 0
        }
    },
    "mappings": {
        "properties": {
            "id": {
                "type": "text",
                "fields": {
                    "raw": {
                        "type": "keyword"
                    }
                }
            },
            "created": {
                "type": "date"
            },
            "startAltitudeMeters": {
                "type": "float"
            },
            "startLocationPoint": {
                "type": "geo_point"
            }
        }
    }
}

然而,当我尝试加载测试 JSON 时使用:

curl -sS -H "Content-Type: application/json" -XPOST localhost:9200/test_write_v1/test?pretty -d {
    "id": "000f4930-b168-3560-b691-78e757524494",
    "created": "2021-09-15T18:26:43.713Z",
    "startLocationPoint": {
        "lat": 34.803279,
        "lon": -119.633169
    },
    "startAltitudeMeters": 30000.0
}

我收到错误:

{
  "error" : {
    "root_cause" : [
      {
        "type" : "illegal_argument_exception",
        "reason" : "can't merge a non object mapping [startLocationPoint] with an object mapping"
      }
    ],
    "type" : "illegal_argument_exception",
    "reason" : "can't merge a non object mapping [startLocationPoint] with an object mapping"
  },
  "status" : 400
}

根据我的研究,Elasticsearch 似乎应该能够理解具有纬度和经度的 GeoPoints。在我看来我的映射也是正确的。

我是不是索引错了?映射有误吗?为什么我会看到此错误?

下面突出显示了问题

curl -sS -H "Content-Type: application/json" -XPOST localhost:9200/test_write_v1/test?pretty -d {
                                                                                  ^
                                                                                  |
                                                                      this should be _doc

基本上,您正在创建一个默认映射(即 _doc 类型),然后您将文档索引到一个名为 test 的特定类型,该类型不使用您的默认值映射。你不应该那样做。