Geopoint 地理点字段类型

Geopoint 地理点字段类型 #

Geopoint 地理点字段类型包含由纬度 latitude 和经度 longitude 指定的地理点。

代码示例 #

创建一个带有 Geopoint 地理点字段类型的映射:

PUT testindex1
{
  "mappings": {
    "properties": {
      "point": {
        "type": "geo_point"
      }
    }
  }
}

地理点格式 #

Geopoint 地理点可以用以下格式索引:

  1. 包含纬度和经度的对象
PUT testindex1/_doc/1
{
  "point": {
    "lat": 40.71,
    "lon": 74.00
  }
}
  1. 写入包含纬度,经度 的文档
PUT testindex1/_doc/2
{
  "point": "40.71,74.00"
}
  1. geohash 格式的文档
PUT testindex1/_doc/3
{
  "point": "txhxegj0uyp3"
}
  1. [经度, 纬度] 格式的数组
PUT testindex1/_doc/4
{
  "point": [74.00, 40.71]
}
  1. Well-Known Text POINT 格式,格式为 “POINT(经度 纬度)”
PUT testindex1/_doc/5
{
  "point": "POINT (74.00 40.71)"
}

参数说明 #

下表列出了 Geopoint 地理点字段类型接受的参数。所有参数都是可选的。

参数描述
ignore_malformed布尔值,指定是否忽略格式错误的值而不抛出异常。纬度的有效值范围是 [-90, 90]。经度的有效值范围是 [-180, 180]。默认为 false
ignore_z_value特定于具有三个坐标的点。如果 ignore_z_value 为 true,则第三个坐标不会被索引,但仍会存储在 _source 字段中。如果 ignore_z_valuefalse,则会抛出异常。
null_value用于替代 null 的值。必须与字段类型相同。如果未指定此参数,当字段值为 null 时,该字段将被视为缺失。默认为 null