The Query widget allows you to retrieve information from source data by executing a predefined query. Data sources can be one of the following:
- Feature layer in the current map
- Feature layer as an item in the portal
- Feature layer from an ArcGIS Server REST service Tip: A feature layer can be from a map service or a feature service
- Imagery layer from an image service
The Query tool serves as a query builder during configuration, allowing you to define the query by specifying source data, filters, and displaying fields in query results. Each query works with a single layer. However, you can define multiple queries for a single app and data layers can be from multiple sources.
- Click the Query tool to open it. A list of queries are shown under the Tasks tab if you have configured more than one query.
- If the tool has only one query and does not ask for input, clicking the tool will run the query and immediately display the results. If the tool has only one query and asks for input, clicking the tool will display the query with user inputs. Note: Input may include an attribute criteria, one or many spatial filters, or a combination of both.
- Click one of the queries. The query may execute differently depending on your configuration.
- If the query does not ask for input, the result shows under the Results tab and the resulting features display on the map with the symbol specified during configuration.
- If Ask for values is checked in the configuration, a text box displays prompting you for a new value for the parameter. The default value initially shows in the box. If unique values are set, the text box will list all of them.
- Using one or more spatial filters.
- Only return features within current map extent—Return features within current map extent.
- Only return features that intersect with the shape drawn on the map—A set of drawing tools can be used to
draw shapes on the map to define the area. Optionally, a search distance can be applied to the shapes.
- Only return features that have a spatial relationship with features in another layer—The results are based
on the spatial relationship between features in the query layer and the related layer. Optionally, a search distance can be applied to the
geometries of the features in the related layer.
- Return features within full extent of the map—Return features within full extent of the map.
- Click Execute to run the query. If the layer has related data, the related records are also included in the results. Features resulting from the query are highlighted on the map with the symbol specified during configuration.
- Taking action on the results set, such as doing statistics and exporting results.
Tip: The maximum features a query can return depends on the maxRecordCount property set in the service. By default, it is 1,000. For example, if the default value is used and 1,300 features are expected to be returned from a query, 1,000 features in the query result panel. Scrolling down the panel will reveal the remaining 300 features.
Alternatively, if the query is performed on a related table, the related features will display in the result.