## ST_WITHIN

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

### Syntax

The syntax for the ST_WITHIN function is as follows:

`ST_WITHIN(geomA, geomB)`

#### Parameters

- `geomA`: This is an expression of type geo_point, cartesian_point, geo_shape, or cartesian_shape. If null, the function returns null.
- `geomB`: This is 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_WITHIN function in ES|QL:

```esql
FROM airport_city_boundaries
| WHERE ST_WITHIN(city_boundary, TO_GEOSHAPE("POLYGON((109.1 18.15, 109.6 18.15, 109.6 18.65, 109.1 18.65, 109.1 18.15))"))
| KEEP abbrev, airport, region, city, city_location
```

In this example, the ST_WITHIN function is used to check if the `city_boundary` is within the specified polygon. The query then keeps the `abbrev`, `airport`, `region`, `city`, and `city_location` fields from the `airport_city_boundaries` index.

```esql
FROM my_index
| WHERE ST_WITHIN(my_geo_point, TO_GEOSHAPE("POLYGON((10 10, 20 20, 30 30, 10 10))"))
| KEEP field1, field2
```

In this second example, the ST_WITHIN function is used to check if the `my_geo_point` field is within the specified polygon. The query then keeps the `field1` and `field2` fields from the `my_index` index.
