Functions
You can use plugin functions in the `filter` clause to filter data. You can also use functions that return a numeric value in the `sort` clause for sorting.
Document fields used as function parameters must be created as an index or a property as specified in the function's documentation.
in_polygon : Checks if a point is inside a polygon. This function is often used to determine if a location is within a delivery area
1. Usage details:
in_polygon(polygon_field, user_x_coordinate, user_y_coordinate, has_multi_polygons=”false”)
2. Parameters:
polygon_field: The name of the field that specifies the delivery area. This field must be of the DOUBLE_ARRAY type. The field value contains the ordered x and y coordinates of the polygon's vertices, where the x-coordinate precedes the y-coordinate. You must specify the vertices in order, either clockwise or counter-clockwise. If the field contains multiple polygons (N), the first value must be N. The next N values must specify the number of vertices for each polygon. The subsequent values are the x and y coordinates for the vertices of each polygon. The value of N must be in the range [1, 50].

user_x_coordinate: The x-coordinate of the user's location. This parameter is of the double type.
user_y_coordinate: The y-coordinate of the user's location. This parameter is of the double type.
has_multi_polygons: Specifies whether the polygon_field contains multiple separate polygons. The default value is false, which indicates a single polygon.
3. Return value:
Returns an integer. If the point is inside a polygon, the function returns the index of the matching polygon. Otherwise, it returns 0.
4. Scenarios:
Scenario 1: Check whether a user is within a merchant's delivery area. For example, assume that the delivery area field is `coordinates` and the user's location is (120.307234, 39.294245). To filter for merchants that deliver to this location, you can write the query as follows:
query=default:'food'&&filter=in_polygon(coordinates, 120.307234, 39.294245)>05. Notes:
The fields used as function parameters must be created as properties.
A maximum of 50 polygons are supported. If this limit is exceeded, the function skips the calculation for the document.
Polygons with holes, such as rings, are not supported.
Polygons that consist of multiple separate parts are not supported.
If the number of coordinates is 0, the function returns 0.
If the number of coordinates is an odd number, the data is considered invalid, and the function returns 0.
If the user's point is on the edge of a polygon, it is considered a successful match, and the function returns 1 or the index of the specific polygon.
The polygon plugin is computationally intensive and can affect query performance. Therefore, you should limit the number of vertices. Run tests based on your specific scenario to determine the optimal number.