The projectdoc Toolbox makes it easy to search for documents with a given set of constraints in an ancestor context.
This tip shows how users of the projectdoc Toolbox for Confluence can constrain their searches to documents that have a property value that is in an ancestor context.
Ancestor Context
What is a property value in an ancestor context?
Documents can be set in a hierarchy. If documents are referenced as property values, the hierarchy of these documents may be of interest in queries.
It is important to note that we refer to the hierarchy of a property value of a document. The hierarchy the document is part of is not important for the ancestor context.
The ancestor context can be traversed from the root to the leaves (downstream) or from a node to its root (upstream).
Suppose you have Role documents for Customer, User, and Operations. Operations has child documents System Admin, Application Admin, and Support. Application Admin is subdivided into Application A Admin, Application B Admin, and Application C Admin.

Suppose further that you provide documentation for people in those roles. Therefore you create instances of the doctype Topic. A topic provides a document property called Audience to define the roles this topic is relevant for.
Topic Title | Audience |
Ops Basics | Operations |
Support Topics | Support |
Common Configuration Options for Applications | Application Admin |
Configuration Options for Application B | Application B Admin |
Now you want to list all documents relevant for Application Admins. This should include all generic documents, but not documents for specific applications.
$<Audience>=^Application Admin^
This will select all documents for the Audience 'Application Admin' and its ancestors (Operations and Role).
Ancestor queries are based on the property information in the blueprint of a document type. Document authors cannot define hierarchies based on document instances. It is the job of template authors to do this, using the property parameter of the Name List Macro (or its relatives).
If you encounter unexpected results with upstream queries, you may want to refresh the doctype cache. This cache collects the relation information from the blueprints. Please refer to Cache Refresh Actions for details on how to access this cache.