diff options
author | Nik Everett <nik9000@gmail.com> | 2017-03-30 22:37:57 -0400 |
---|---|---|
committer | Nik Everett <nik9000@gmail.com> | 2017-03-31 09:11:54 -0400 |
commit | 653f50973ac7d7195339d1f774a532f7c5bee2f4 (patch) | |
tree | abd53b3d5739bef227fbb978b6c4b25ae63e4165 /docs/reference | |
parent | f5d41dfc9d5113301c97debbb496325c422cf14c (diff) |
CONSOLEify geo-shape docs
`CONSOLE`ify geo-shape type and geo-shape query docs.
Relates to #18160
Diffstat (limited to 'docs/reference')
-rw-r--r-- | docs/reference/mapping/types/geo-shape.asciidoc | 50 | ||||
-rw-r--r-- | docs/reference/query-dsl/geo-shape-query.asciidoc | 76 |
2 files changed, 98 insertions, 28 deletions
diff --git a/docs/reference/mapping/types/geo-shape.asciidoc b/docs/reference/mapping/types/geo-shape.asciidoc index 4fe185fe46..18ffdbcbc6 100644 --- a/docs/reference/mapping/types/geo-shape.asciidoc +++ b/docs/reference/mapping/types/geo-shape.asciidoc @@ -156,16 +156,23 @@ cell right next to it -- even though the shape is very close to the point. [source,js] -------------------------------------------------- +PUT /example { - "properties": { - "location": { - "type": "geo_shape", - "tree": "quadtree", - "precision": "1m" + "mappings": { + "doc": { + "properties": { + "location": { + "type": "geo_shape", + "tree": "quadtree", + "precision": "1m" + } + } } } } -------------------------------------------------- +// CONSOLE +// TESTSETUP This mapping maps the location field to the geo_shape type using the quad_tree implementation and a precision of 1m. Elasticsearch translates @@ -240,6 +247,7 @@ API. [source,js] -------------------------------------------------- +POST /example/doc { "location" : { "type" : "point", @@ -247,6 +255,7 @@ API. } } -------------------------------------------------- +// CONSOLE [float] ===== http://geojson.org/geojson-spec.html#id3[LineString] @@ -257,6 +266,7 @@ line. Specifying more than two points creates an arbitrary path. [source,js] -------------------------------------------------- +POST /example/doc { "location" : { "type" : "linestring", @@ -264,6 +274,7 @@ line. Specifying more than two points creates an arbitrary path. } } -------------------------------------------------- +// CONSOLE The above `linestring` would draw a straight line starting at the White House to the US Capitol Building. @@ -277,6 +288,7 @@ closed). [source,js] -------------------------------------------------- +POST /example/doc { "location" : { "type" : "polygon", @@ -286,12 +298,14 @@ closed). } } -------------------------------------------------- +// CONSOLE The first array represents the outer boundary of the polygon, the other arrays represent the interior shapes ("holes"): [source,js] -------------------------------------------------- +POST /example/doc { "location" : { "type" : "polygon", @@ -302,6 +316,8 @@ arrays represent the interior shapes ("holes"): } } -------------------------------------------------- +// CONSOLE +// TEST[skip:https://github.com/elastic/elasticsearch/issues/23836] *IMPORTANT NOTE:* GeoJSON does not mandate a specific order for vertices thus ambiguous polygons around the dateline and poles are possible. To alleviate ambiguity @@ -322,6 +338,7 @@ OGC standards to eliminate ambiguity resulting in a polygon that crosses the dat [source,js] -------------------------------------------------- +POST /example/doc { "location" : { "type" : "polygon", @@ -332,6 +349,8 @@ OGC standards to eliminate ambiguity resulting in a polygon that crosses the dat } } -------------------------------------------------- +// CONSOLE +// TEST[skip:https://github.com/elastic/elasticsearch/issues/23836] An `orientation` parameter can be defined when setting the geo_shape mapping (see <<geo-shape-mapping-options>>). This will define vertex order for the coordinate list on the mapped geo_shape field. It can also be overridden on each document. The following is an example for @@ -339,6 +358,7 @@ overriding the orientation on a document: [source,js] -------------------------------------------------- +POST /example/doc { "location" : { "type" : "polygon", @@ -350,6 +370,8 @@ overriding the orientation on a document: } } -------------------------------------------------- +// CONSOLE +// TEST[skip:https://github.com/elastic/elasticsearch/issues/23836] [float] ===== http://www.geojson.org/geojson-spec.html#id5[MultiPoint] @@ -358,6 +380,7 @@ A list of geojson points. [source,js] -------------------------------------------------- +POST /example/doc { "location" : { "type" : "multipoint", @@ -367,6 +390,7 @@ A list of geojson points. } } -------------------------------------------------- +// CONSOLE [float] ===== http://www.geojson.org/geojson-spec.html#id6[MultiLineString] @@ -375,6 +399,7 @@ A list of geojson linestrings. [source,js] -------------------------------------------------- +POST /example/doc { "location" : { "type" : "multilinestring", @@ -386,6 +411,8 @@ A list of geojson linestrings. } } -------------------------------------------------- +// CONSOLE +// TEST[skip:https://github.com/elastic/elasticsearch/issues/23836] [float] ===== http://www.geojson.org/geojson-spec.html#id7[MultiPolygon] @@ -394,18 +421,20 @@ A list of geojson polygons. [source,js] -------------------------------------------------- +POST /example/doc { "location" : { "type" : "multipolygon", "coordinates" : [ [ [[102.0, 2.0], [103.0, 2.0], [103.0, 3.0], [102.0, 3.0], [102.0, 2.0]] ], - [ [[100.0, 0.0], [101.0, 0.0], [101.0, 1.0], [100.0, 1.0], [100.0, 0.0]], [[100.2, 0.2], [100.8, 0.2], [100.8, 0.8], [100.2, 0.8], [100.2, 0.2]] ] ] } } -------------------------------------------------- +// CONSOLE +// TEST[skip:https://github.com/elastic/elasticsearch/issues/23836] [float] ===== http://geojson.org/geojson-spec.html#geometrycollection[Geometry Collection] @@ -414,6 +443,7 @@ A collection of geojson geometry objects. [source,js] -------------------------------------------------- +POST /example/doc { "location" : { "type": "geometrycollection", @@ -430,7 +460,8 @@ A collection of geojson geometry objects. } } -------------------------------------------------- - +// CONSOLE +// TEST[skip:https://github.com/elastic/elasticsearch/issues/23836] [float] ===== Envelope @@ -441,6 +472,7 @@ bounding rectangle: [source,js] -------------------------------------------------- +POST /example/doc { "location" : { "type" : "envelope", @@ -448,6 +480,8 @@ bounding rectangle: } } -------------------------------------------------- +// CONSOLE +// TEST[skip:https://github.com/elastic/elasticsearch/issues/23836] [float] ===== Circle @@ -457,6 +491,7 @@ point with a radius: [source,js] -------------------------------------------------- +POST /example/doc { "location" : { "type" : "circle", @@ -465,6 +500,7 @@ point with a radius: } } -------------------------------------------------- +// CONSOLE Note: The inner `radius` field is required. If not specified, then the units of the `radius` will default to `METERS`. diff --git a/docs/reference/query-dsl/geo-shape-query.asciidoc b/docs/reference/query-dsl/geo-shape-query.asciidoc index 1220306133..00fd3b5609 100644 --- a/docs/reference/query-dsl/geo-shape-query.asciidoc +++ b/docs/reference/query-dsl/geo-shape-query.asciidoc @@ -6,7 +6,7 @@ Filter documents indexed using the `geo_shape` type. Requires the <<geo-shape,`geo_shape` Mapping>>. The `geo_shape` query uses the same grid square representation as the -geo_shape mapping to find documents that have a shape that intersects +`geo_shape` mapping to find documents that have a shape that intersects with the query shape. It will also use the same PrefixTree configuration as defined for the field mapping. @@ -17,28 +17,44 @@ examples. ==== Inline Shape Definition -Similar to the `geo_shape` type, the `geo_shape` Filter uses +Similar to the `geo_shape` type, the `geo_shape` query uses http://www.geojson.org[GeoJSON] to represent shapes. -Given a document that looks like this: +Given the following index: [source,js] -------------------------------------------------- +PUT /example { - "name": "Wind & Wetter, Berlin, Germany", - "location": { - "type": "Point", - "coordinates": [13.400544, 52.530286] + "mappings": { + "doc": { + "properties": { + "location": { + "type": "geo_shape" + } + } } + } +} + +POST /example/doc?refresh +{ + "name": "Wind & Wetter, Berlin, Germany", + "location": { + "type": "point", + "coordinates": [13.400544, 52.530286] + } } -------------------------------------------------- +// CONSOLE +// TESTSETUP The following query will find the point using the Elasticsearch's `envelope` GeoJSON extension: [source,js] -------------------------------------------------- -GET /_search +GET /example/_search { "query":{ "bool": { @@ -83,25 +99,43 @@ shape: [source,js] -------------------------------------------------- -GET /_search +PUT /shapes +{ + "mappings": { + "doc": { + "properties": { + "location": { + "type": "geo_shape" + } + } + } + } +} + +PUT /shapes/doc/deu +{ + "location": { + "type": "envelope", + "coordinates" : [[13.0, 53.0], [14.0, 52.0]] + } +} + +GET /example/_search { "query": { "bool": { - "must": { - "match_all": {} - }, - "filter": { - "geo_shape": { - "location": { - "indexed_shape": { - "id": "DEU", - "type": "countries", - "index": "shapes", - "path": "location" - } + "filter": { + "geo_shape": { + "location": { + "indexed_shape": { + "index": "shapes", + "type": "doc", + "id": "deu", + "path": "location" } } } + } } } } |