地理点字段类型
地理点字段类型包含由纬度和经度指定的地理点。
示例
创建一个具有地理点字段类型的映射:
PUT testindex1
{
"mappings": {
"properties": {
"point": {
"type": "geo_point"
}
}
}
}
格式
地理点可以以下格式索引:
具有纬度和经度的对象
PUT testindex1/_doc/1
{
"point": {
"lat": 40.71,
"lon": 74.00
}
}
字符串在“latitude,longitude”格式
PUT testindex1/_doc/2
{
"point": "40.71,74.00"
}
geohash
PUT testindex1/_doc/3
{
"point": "txhxegj0uyp3"
}
一个在 [longitude, latitude] 格式的数组
PUT testindex1/_doc/4
{
"point": [74.00, 40.71]
}
一个已知的文本点,格式为“POINT(longitudelatitude)”
PUT testindex1/_doc/5
{
"point": "POINT (74.00 40.71)"
}
GeoJSON格式,其中coordinates为[b1]、[b2]格式
PUT testindex1/_doc/6
{
"point": {
"type": "Point",
"coordinates": [74.00, 40.71]
}
}
参数
以下表格列出了 geopoint 字段类型接受的参数。所有参数都是可选的。
| 参数 | 描述 |
|---|---|
| ignore_malformed | 布尔值,指定忽略格式错误的值且不抛出异常。纬度的有效值是[-90, 90]。经度的有效值是[-180, 180]。默认值是false。 |
| ignore_z_value | 针对具有三个坐标的点。如果ignore_z_value是true,第三个坐标未进行索引但仍然存储在_source字段中。如果ignore_z_value是false,则会抛出异常。 |
| null_value | 一个用于替换null的值。必须与字段类型相同。如果未指定此参数,当字段的值为null时,字段被视为缺失。默认为null。 |