原英文版地址: https://www.elastic.co/guide/en/elasticsearch/reference/7.7/geo-point.html, 原文档版权归 www.elastic.co 所有
本地英文版地址: ../en/geo-point.html
本地英文版地址: ../en/geo-point.html
重要: 此版本不会发布额外的bug修复或文档更新。最新信息请参考 当前版本文档。
geo_point类型的字段接受经度-纬度对,可用于:
- 查找边界框(bounding box)内、中心点的特定距离(distance)内、多边形(polygon)内或geo_shape查询内的地理坐标点。
- 按地理位置或离中心点的距离(distance)来聚合文件。
- 将距离整合到文档的相关性评分中。
- 按距离排序(sort)文档。
有五种方法可以指定 geo-point,如下所示:
PUT my_index
{
"mappings": {
"properties": {
"location": {
"type": "geo_point"
}
}
}
}
PUT my_index/_doc/1
{
"text": "Geo-point as an object",
"location": {
"lat": 41.12,
"lon": -71.34
}
}
PUT my_index/_doc/2
{
"text": "Geo-point as a string",
"location": "41.12,-71.34"
}
PUT my_index/_doc/3
{
"text": "Geo-point as a geohash",
"location": "drm3btev3e86"
}
PUT my_index/_doc/4
{
"text": "Geo-point as an array",
"location": [ -71.34, 41.12 ]
}
PUT my_index/_doc/5
{
"text": "Geo-point as a WKT POINT primitive",
"location" : "POINT (-71.34 41.12)"
}
GET my_index/_search
{
"query": {
"geo_bounding_box": {
"location": {
"top_left": {
"lat": 42,
"lon": -72
},
"bottom_right": {
"lat": 40,
"lon": -74
}
}
}
}
}
|
表示为对象的geo-point,带有 |
|
|
以字符串形式表示的geo-point,格式为: |
|
|
表示为 geohash 的geo-point。 |
|
|
以数组形式表示的geo-point,格式为:[ |
|
|
表示为众所周知的文本点,格式为: |
|
|
一种地理边界框查询,用于查找落在该框内的所有 geo-point。 |
表示为数组或字符串的 geo-point
请注意,字符串格式的 geo-point 按 lat,lon排序,而数组格式的 geo-point 按相反顺序排序:lon,lat。
最初,lat,lon顺序都在数组和字符串中使用,但是数组格式在早期被改变以符合 GeoJSON 使用的格式。
geo_point字段接受以下参数:
|
如果为 |
|
|
|
如果为 |
|
接受 geo-point 值,该值将替代任何显式的 |