A geo-polygon query allows you to specify a polygon geographical area as a query condition. Tablestore returns the rows in which the value of the specified field falls within the polygon geographical area.
API operations
You can set the query type to GeoPolygonQuery in the Search or ParallelScan operation to perform geo-polygon queries.
Parameters
|
Parameter |
Description |
|
fieldName |
The name of the column that you want to query. The value of this parameter is of the GEOPOINT data type. |
|
points |
The coordinate pairs of the points that define polygon geographical area. This parameter value must be in the format of |
|
query |
The query statement for the search index. Set this parameter to GeoPolygonQuery. |
|
getTotalCount |
Specifies whether to return the total number of rows that meet the query conditions. The default value of this parameter is false, which specifies that the total number of rows that meet the query conditions is not returned. If you set this parameter to true, the query performance is compromised. |
|
tableName |
The name of the data table. |
|
indexName |
The name of the search index. |
|
columnsToGet |
Specifies whether to return all columns of each row that meets the query conditions. You can specify the returnAll and columns fields for this parameter. The default value of the returnAll field is false, which specifies that not all columns are returned. In this case, you can use the columns field to specify the columns that you want to return. If you do not specify the columns that you want to return, only the primary key columns are returned. If you set the returnAll field to true, all columns are returned. |
Methods
You can perform geo-polygon queries by using the Tablestore console, Tablestore CLI, and Tablestore SDKs. Before you perform geo-polygon queries, make sure that the following prerequisites are met:
Use an Alibaba Cloud account or a RAM user with the required permissions for Table Store operations. To grant permissions to a RAM user, see Grant permissions to a RAM user by using a RAM policy.
If you use an SDK or a command-line tool, create an AccessKey for your Alibaba Cloud account or RAM user if you do not have one.
You have created a data table.
A Search Index has been created for the data table.
If you use an SDK, initialize the Tablestore Client.
If you use the command-line tool, download and start the tool, then configure the connection to your instance and select the target table. For more information, see Download the command-line tool, Start the tool and configure connection information, and Data table operations.
Billing
In VCU mode (formerly reserved mode), Search Index queries consume VCU compute resources. In CU mode (formerly pay-as-you-go mode), they consume read throughput. For more information, see Search Index metering and billing.
FAQ
References
Search Index supports various query types for multi-dimensional data queries, including term query, terms query, match all query, match query, phrase match query, range query, prefix query, suffix query, wildcard query, token-based wildcard query, boolean query, geo query, nested query, vector search, and exists query.
When you query data, you can sort and paginate the result set or perform collapsing (deduplication).
For data analysis, such as finding the maximum or minimum value, calculating a sum, or counting rows, you can use the statistical aggregation or SQL query features.
To quickly export data regardless of the result set order, you can use the Parallel Scan feature.