GEOWITHIN
The GEOWITHIN
field specifier (case sensitive) allows you to find documents that have a document field that describes a location region that wholly fits within a specified geometric shape.
In the following examples, the shapes used in the queries are represented by black dotted lines, and the shapes in matching documents are represented by solid green lines.
Query with... | Query results... |
---|---|
POLYGON |
Polygons, lines, and points contained wholly within the specified polygon.
If a document contains a MULTIPOLYGON, MULTILINESTRING, or MULTIPOINT, the document is returned only when the entire shape is wholly contained within the query polygon. |
LINESTRING |
Lines and points that occur within or on the specified line.
If a document contains a MULTILINESTRING or MULTIPOINT, the document is returned only when every line or point is located within or on the query line. |
POINT | A point that is an exact match to the specified point. |
MULTIPOLYGON | Geometric shapes contained wholly within one or more of the polygons in the MULTIPOLYGON. |
MULTILINESTRING | Geometric shapes contained wholly within or on one or more of the lines in the MULTILINESTRING. |
MULTIPOINT | A point that matches a point in the MULTIPOINT, a MULTIPOINT that is a subset of the query MULTIPOINT, or an identical MULTIPOINT. |
GEOMETRYCOLLECTION | Geometric shapes contained wholly within one or more of the objects in the GEOMETRYCOLLECTION. |
Format
FieldText=GEOWITHIN{GEOMETRY}:POSITION
GEOMETRY
|
The geometric shape to query with, in Well-Known Text (WKT) format. For information about how to specify the shape, see Supported Well-Known Text Geometric Objects. |
POSITION
|
The document field containing the position information. This field must contain unified geospatial location information. You can specify multiple field names, in the form |
NOTE: You can optimize this field specifier by configuring the position field with the
Example
FieldText=GEOWITHIN{POLYGON((1 1, -1 1, 0 -2, 1 -1))}:LOCATION
This example matches all documents where the geospatial region described by the LOCATION
field is within the quadrilateral with vertices at (1,1), (-1,1), (0,-2), (1,-1).
FieldText=GEOWITHIN{LINESTRING(10 50, 50 30, 20 10)}:POSITION
This example matches all documents where the position field matches any point on the specified multi-segment line, or any line that is part of the specified multi-segment line. If a document contains a MULTILINESTRING or MULTIPOINT, the document is returned only when every line or point is located within or on the query line.