0

My_Json_File

{
"addressInfo": {
    "city": "Wimsheim",
    "postcode": "71299",
    "geopoint": {
        "lon": 48.845877,
        "lat": 8.821861,
        "alt": 0.0
    }
},
"_id": "ac169008-aa5b-4b09-aa9e-3bf3018f316d"
}    
  • 请就如何在地理点和 “_id”字段中遇到这个“alt”字段提供建议,并为上述 JSON 文件编写合适的映射。

更新 1

My_Json_File

{
"_id": "ac169008-aa5b-4b09-aa9e-3bf3018f316d"
"addressInfo": {
    "city": "Wimsheim",
    "postcode": "71299",
    "geopoint": {
        "lon": 48.845877,
        "lat": 8.821861,
        "alt": 0.0
    }
},
"prices": [{
    "fuelType": "DIESEL",
    "price": "52.09"
}, {
    "fuelType": "PETROL",
    "price": "66.20"
},{
   "fuelType": "AUTOGAS",
    "price": "66.20"
}]
}
4

1 回答 1

1

在您的位置上,我会将“alt”移出地理点并使用映射类型“geo_point”,它为地理点字段的进一步操作提供了许多其他选项。

它看起来像:

{
    "_id": "ac169008-aa5b-4b09-aa9e-3bf3018f316d"
    "addressInfo": {
        "city": "Wimsheim",
        "postcode": "71299",
        "geopoint": {
            "lon": 48.845877,
            "lat": 8.821861,
        },
        "alt": 0.0
    },
} 

和映射应该看起来像:

  "properties": {
    "_id": {
      "type": "string"
    },
    "addressInfo": {
      "type": "nested",
      "properties": {
        "city": {
          "type": "string",
        },
        "postcode": {
          "type": "integer",
        },
        "alt": {
          "type": "float",
        },
        "geopoint": {
          "type": "geo_point",
        },
      },
    },
  },

其中 geo_point 类型字段接收如下数据:

{"lat": 8.821861, "lon": 48.845877}
于 2016-04-20T10:51:34.953 回答