About queries
Queries provide a means of asking questions about the features of an ArcGIS map service or feature service and getting results that meet the criteria you specify; for example, a query for earthquakes might return which recent earthquakes were of a certain magnitude or greater, or a query of forest fires might return a list of those fires that had a minimum acreage size and which agency was the responsible administrative body.
Queries are listed in the Queries panel. The results of a query are the set of features which satisfy the query definition criteria. When a query is executed, these features are displayed on the map, and are also listed in the Query Results panel at the right of the map. After executing a query, you can inspect the attributes of each feature and also zoom the map to show the selected feature, or zoom the map to the extent of all the features.
Queries are saved as part of the map. If you save the map after creating a query, the query will be stored as part of the map. Other users of the map may execute the query and even revise its properties, saving a copy for themselves.
Queryable layers
Queries can be defined on any layer based on an ArcGIS map or feature service which has been published with a query service. You can find out if a layer has a query service by referring to the service details. In the Layers panel, click the arrow next to the layer to open Layer Details, and click Service Details. In the web page which opens, click the Supported Interfaces: REST link at the bottom of the page to open the JSON definition of the service. At the bottom of this definition you will see a Capabilities list, which will include Query for a queryable layer.
Types of queries
When a query is executed, it may ask the user for a parameter to use in the query, depending on how the query was defined.
- Simple queries use the same query expression each time they are executed. Simple queries are generally performed when a one-time question needs to be asked about a layer, or when the same query needs to be performed on a routine basis because the data associated with the query changes frequently.
- Parametric queries allow you to specify different criteria for one or more query parameters each time the query is executed. Parametric queries are generally used to allow user input that may vary with each use.
You can combine a simple query with a parametric query, for example you might want to limit demographic information to a particular state, but prompt for the age range, thus producing different results each time the query is executed.