## ST_CONTAINS

ST_CONTAINS is a function in ES|QL that checks whether the first geometry contains the second geometry. This function is the inverse of the ST_WITHIN function.

### Syntax

The syntax for the ST_CONTAINS function is as follows:

`ST_CONTAINS(geomA, geomB)`

#### Parameters

- `geomA`: An expression of type geo_point, cartesian_point, geo_shape or cartesian_shape. If null, the function returns null.
- `geomB`: An expression of type geo_point, cartesian_point, geo_shape or cartesian_shape. If null, the function returns null. The second parameter must also have the same coordinate system as the first. This means it is not possible to combine geo_* and cartesian_* parameters.

### Examples

Here are a couple of examples of how to use the ST_CONTAINS function in ES|QL queries:

```esql
FROM airport_city_boundaries
| WHERE ST_CONTAINS(city_boundary, TO_GEOSHAPE("POLYGON((109.35 18.3, 109.45 18.3, 109.45 18.4, 109.35 18.4, 109.35 18.3))"))
| KEEP abbrev, airport, region, city, city_location
```

In this example, the ST_CONTAINS function is used to check if the `city_boundary` contains the specified polygon. The query then keeps the `abbrev`, `airport`, `region`, `city`, and `city_location` fields.

```esql
FROM geo_shapes
| WHERE ST_CONTAINS(shape_field, TO_GEOSHAPE("POINT(10 20)"))
| KEEP id, name, shape_field
```

In this second example, the ST_CONTAINS function is used to check if the `shape_field` contains the specified point. The query then keeps the `id`, `name`, and `shape_field` fields.
