- 00 - The Beginning
- 01 - Finding nodes with a bounding box
- 02 - Outputting data about nodes
- 03 - Filtering nodes that have a tag
- 04 - Find nodes by matching tags and their values
- 05 - Find nodes by applying multiple filters
- 06 - Extracting multiple sets of nodes
- 07 - Calculating differences between results
- 08 - Generating JSON output
- 09 - Generating CSV output
- 10 - The default set
- 11 - Querying a set
- 12 - Searching within a radius using around
- 13 - Using around to filter against a set of results
- 14 - Searching by polygon
- 15 - Finding ways
- 16 - Ways and their nodes
- 17 - Ways and their tags
- 18 - Combining node and way queries
- 19 - Finding ways from their nodes
- 20 - Finding relations
- 21 - Type agnostic queries (nwr)
- 22 - Areas
- 23 - Finding the areas enclosing a feature
- 24 - Find the area derived from a feature
- 25 - Areas via Nominatim search
- 26 - Timeouts and endpoints
11 - Querying a set
This query demonstrates syntax for querying and serialising the contents of a named set.
Rather than work with the default set, this query only uses named sets. This illustrates how every statement works with data from an input set and stores its results in an output set.
First we find nodes that have a name and store them in a set of results called "named_nodes".
Set names can include letters, digits and the underscore character. But names must not start with a digit.
Secondly, we then query within that first set of results, filtering to just those nodes that are tagged as a cave entrance.
For node queries we append the name of the set to the keyword using a dotted syntax:
This means the statement will use that set rather than the OSM database.
node.named_nodes means "Query nodes found in the set 'named_nodes'". The
nodes are then filtered based on the value of their
The results of that query are written to another named set. This time called
Finally, we output the contents of the
This query is a little artificial as we can achieve the same thing by querying the database directly. But in more complex queries you may be working with multiple sets of results that you want to filter, explore and output in different ways.
We can also output results from different sets through repeated uses of the
out keyword that reference different sets.
Every OverpassQL query command can work with named sets as well as the default
_" set. They can also store their results in named sets. This provides a
great deal of flexibility.