AQS Builder
Use the AQS Builder to construct AQS queries
AQS is a powerful tool for querying your data in Alloy. The AQS Builder provides a visual way for you to easily construct your own queries, without needing to write any code!
Open the AQS Builder
You can specify an AQS query when:
- populating the default value of an AQS attribute when editing a design/interface
- populating an AQS attribute on an item
- adding a Filter or Query action to a workflow
- creating an AQS data source in the Report Builder
- adding a layer style with a Custom Query type
- managing the queries on dashboard cards
Selecting an AQS field will open the AQS Builder, where you can build your desired query.
In Data Explorer
You can also open the AQS Builder from the Data Explorer, which will display the results of your query as a table (items as rows, selected attributes as columns). Therefore, if you're learning AQS, we recommend practising in the Data Explorer!
To create a new query and see the results:
-
Select in the right panel menu to open the Data Explorer.
-
Select at the top to create a new query.
-
Choose the design/interface you want to query.
-
Select Menu (bottom-right) and choose AQS Builder.
-
Build your query and then select Done.
The AQS Builder workspace
1 Title
This is either the design/interface you're querying or the name of a saved query.
2 Root node
All queries start with a root node. Its icon resembles the design/interface you're querying. The root node defines various properties of the query and fetches an initial set of items.
Select it to change things like:
- the AQS type (Query, Statistics, Join)
- the design/interface of items to be queried
- the collection of items to be queried
- the item attributes you want to see data for
- how items are sorted/grouped
For more detail, see Root node types.
3 Add a child node
To filter the items fetched by your root node, you can add one or more child nodes.
A child node imposes a condition that items must fulfil in order to be fetched by the query. To learn about the different types and what they do, see Child node types.
To add a child node, select the icon extending from a previous node, and then choose the child node type you want.
For more detail, see Building an AQS query.
4 Add a parameter
A parameter is a placeholder for a value that will be provided when the query runs. This lets you build a query without having to provide an actual value.
Parameters are accessible to all nodes in a query, so they're useful for supplying the same value to multiple nodes.
For more detail, see AQS Parameters.
5 Save query
Select this to save the query in Alloy.
To overwrite an existing query, disable Save as new query, select Overwrite query and choose one from the list. Alternatively, enable Save as new query.
Input a Name and then select Save to finish.
6 Load query
Select this to load a query that's saved in Alloy. It'll replace the current query you're working on, so be sure to save the current query first if you want to keep it.
7 View JSON
Select this to view the underlying JSON code of your current query.
You can edit the code directly here! When you select Done, the AQS Builder will refresh to show your modified query (providing your code changes are valid).
If you're learning AQS (particularly if you intend to run queries via the Alloy API), this can be useful for understanding its structure and syntax.
8 Done
Select Done to finish building your query and close the AQS Builder. To leave without saving, select in the top-right corner.
If you selected a field to open the AQS Builder, it will now be populated with your query.
If you're using the Data Explorer, Alloy will run the query and display the results.
Examples
To learn more about building different types of query in the AQS Builder, here are some step-by-step examples:
- Example 1 - Check an attribute
- Example 2 - Geographic
- Example 3 - Logical branches
- Example 4 - Parameters and AQS Join
To learn more about the different node types and see illustrations of each one in use, see Root node types and Child node types.