opensearch-docs-cn/_field-types/xy-point.md

2.8 KiB

layout title nav_order has_children parent grand_parent redirect_from
default xy point 58 false Cartesian field types Supported field types
/opensearch/supported-field-types/xy-point/

xy point field type

An xy point field type contains a point in a two-dimensional Cartesian coordinate system, specified by x and y coordinates. It is based on the Lucene XYPoint field type. The xy point field type is similar to the geopoint field type, but does not have the range limitations of geopoint. The coordinates of an xy point are single-precision floating-point values. For information about the range and precision of floating-point values, see Numeric field types.

Example

Create a mapping with an xy point field type:

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

{% include copy-curl.html %}

Formats

xy points can be indexed in the following formats:

  • An object with x and y coordinates
PUT testindex1/_doc/1
{
  "point": { 
    "x": 0.5,
    "y": 4.5
  }
}

{% include copy-curl.html %}

  • A string in the "x, y" format
PUT testindex1/_doc/2
{
  "point": "0.5, 4.5" 
}

{% include copy-curl.html %}

  • An array in the [x, y] format
PUT testindex1/_doc/3
{
  "point": [0.5, 4.5] 
}

{% include copy-curl.html %}

PUT testindex1/_doc/4
{
  "point": "POINT (0.5 4.5)"
}

{% include copy-curl.html %}

  • GeoJSON format
PUT testindex1/_doc/5
{
  "point" : {
    "type" : "Point",
    "coordinates" : [0.5, 4.5]        
  }
}

{% include copy-curl.html %}

In all xy point formats, the coordinates must be specified in the x, y order. {: .note}

Parameters

The following table lists the parameters accepted by xy point field types. All parameters are optional.

Parameter Description
ignore_malformed A Boolean value that specifies to ignore malformed values and not to throw an exception. Default is false.
ignore_z_value Specific to points with three coordinates. If ignore_z_value is true, the third coordinate is not indexed but is still stored in the _source field. If ignore_z_value is false, an exception is thrown.
null_value A value to be used in place of null. The value must be of the same type as the field. If this parameter is not specified, the field is treated as missing when its value is null. Default is null.