加载中

点字段类型

point 数据类型便于索引和搜索落入二维平面坐标系中的任意 x, y 坐标对。

您可以使用 shape 查询来查询使用此类型的文档。

geo_shapegeo_point 一样,point 可以使用 GeoJSONWell-Known Text 格式指定。但是,出于便利和历史原因,还支持许多其他格式。总共有五种指定笛卡尔点的方法,如下所示

				PUT my-index-000001
					{
  "mappings": {
    "properties": {
      "location": {
        "type": "point"
      }
    }
  }
}
				PUT my-index-000001/_doc/1
					{
  "text": "Point as an object using GeoJSON format",
  "location": {
    "type": "Point",
    "coordinates": [-71.34, 41.12]
  }
}
				PUT my-index-000001/_doc/2
					{
  "text": "Point as a WKT POINT primitive",
  "location" : "POINT (-71.34 41.12)"
}
				PUT my-index-000001/_doc/3
					{
  "text": "Point as an object with 'x' and 'y' keys",
  "location": {
    "x": -71.34,
    "y": 41.12
  }
}
				PUT my-index-000001/_doc/4
					{
  "text": "Point as an array",
  "location": [ -71.34, 41.12 ]
}
				PUT my-index-000001/_doc/5
					{
  "text": "Point as a string",
  "location": "-71.34,41.12"
}
		
  1. 以对象形式表示的点,采用 GeoJSON 格式,包含 typecoordinates 键。
  2. Well-Known Text POINT 形式表示的点,格式为:"POINT(x y)"
  3. 以对象形式表示的点,包含 xy 键。
  4. 以数组形式表示的点,格式为:[ x, y]
  5. 以字符串形式表示的点,格式为:"x,y"
注意

geo-point 字段类型不同,坐标 xy 的顺序在上述所有格式中都是相同的。

提供给索引器的坐标是单精度浮点值,因此该字段保证了由 Java 虚拟机提供的相同精度(通常为 1E-38)。

point 字段接受以下参数

ignore_malformed
如果为 true,则忽略格式错误的点。如果为 false(默认值),格式错误的点会抛出异常并拒绝整个文档。
ignore_z_value
如果为 true(默认值),将接受三维点(存储在 source 中),但仅对 x 和 y 值建立索引;第三个维度将被忽略。如果为 false,包含超过 x 和 y(两个维度)值的点将抛出异常并拒绝整个文档。
null_value
接受一个点值,用于替代任何显式的 null 值。默认为 null,这意味着该字段被视为缺失。

目前无法对点进行排序或直接检索其字段。point 值只能通过 _source 字段检索。

© . This website operates independently and is not affiliated with or endorsed by Elasticsearch B.V. All brand names, logos, and trademarks are the property of their respective owners.