GEOCONTAINS

The GEOCONTAINS field specifier (case sensitive) allows you to find documents that have a document field that describes a location region that contains 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 that contain the specified polygon.

If a document field contains a multi-polygon or geometry collection, the document is returned when any part of it contains the query polygon.

LINESTRING

Polygons or lines, or multi-polygons or multi-lines, that contain the specified line.

POINT

Polygons or multi-polygons that contain the point, lines or multi-lines on which the point occurs, multi-points that contain the point, and points that exactly match the point.

MULTIPOLYGON

Polygons or multi-polygons that contain the entire MULTIPOLYGON.

MULTILINESTRING Geometric shapes that contain all of the lines in the MULTILINESTRING.
MULTIPOINT

Geometric shapes that contain all of the points in the MULTIPOINT.

GEOMETRYCOLLECTION

Geometric shapes that contain all of the objects in the GEOMETRYCOLLECTION.

Format

FieldText=GEOCONTAINS{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 POSITION1:POSITION2:POSITION3, and so on. A document is returned if at least one of the fields meets the requirements of the query.

NOTE: You can optimize this field specifier by configuring the position field with the field property.

Example

FieldText=GEOCONTAINS{POINT(0 0)}:LOCATION

This example matches all documents where the geospatial region described by the LOCATION field contains the point (0,0).