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
A feature layer can be from a map service or a feature service.
- Imagery layer from an image service
When running a query against a table with related records, all the related features are highlighted on the map and listed in the Query panel.
The Query widget 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
Using the Query widget
The following steps explain how to use the Query widget:
- Click the Query widget to open it. A list of queries is shown on the Tasks tab if you have configured more than one query.
If the widget only has one query, and it does not ask for input from end users, clicking the widget will run the query and immediately display the results.
If the widget only has one query, and it asks for input from end users, clicking the widget will display the query with user inputs.
The input from end users can include 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 is shown on the Results tab, and the resulting features display on the map with the symbol you specified during the 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 them all.
- You can use one or more spatial filters.
- Only return features within current map extent—Return features within the 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 features in 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 the full extent of the map.
Features resulting from the query are highlighted on the map with the symbol you specified during the configuration. If the layer has related data, the related records are also included in the results.
The maximum number of features a query can return depends on the maxRecordCount property set in the service. The default is 1,000. For example, if you take the default value and expect 1,300 features to return from a query, you will first see 1,000 features in the query result panel. When you scroll down the panel, you will see the remaining 300 features.
Alternatively, if the query is performed on a related table, all the related features are highlighted on the map and listed in the Query panel.