Feature 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 to sort data.
Create an index or property for any document field that you use as a function parameter. Follow the instructions in the function's documentation.
in_query_polygon: Checks if a point is inside a specified polygon
1. Usage instructions
in_query_polygon(polygon_key, doc_point)
2. Parameters:
polygon_key: The key for a user-defined parameter in the kvpairs clause. The value of this key stores the polygon vertices. The type must be DOUBLE_ARRAY. The value must be a comma-separated list of the x and y coordinates of the polygon's ordered vertices, such as xA,yA,xB,yB. The order can be clockwise or counter-clockwise. To specify multiple polygons, separate them with a semicolon (;).
doc_point: The point to check. The type must be DOUBLE_ARRAY and contain two values: the x and y coordinates of the point.
3. Return value:
int. Returns the 1-based index of the first polygon that contains the point. For example, the function returns 1 for the first polygon and 2 for the second. If the point is not in any polygon, the function returns 0.
4. Scenarios:
Scenario 1:
Search for a restaurant named 'Wai Po Jia' within the Intime shopping area (xA,yA,xB,yB,xC,yC;xD,yD,xE,yE,xF,yF,xG,yG). The location of the restaurant is stored in the point field.
query=default:'Wai Po Jia'&&filter=in_query_polygon("polygons", point)>0&&kvpairs=polygons:xA\,yA\,xB\,Yb\,xC\,Yc;xD\,yD\,xE\,yE\,xF\,yF\,xG\,yG5. Notes:
Create properties for the fields that you use as function parameters.