CQL field
ancestor in CQL: syntax and examples (Confluence)
ancestor returns every page that sits anywhere below a given page: children, grandchildren and deeper. You give it the numeric content id of the top page. It is the field to use for "everything in this handbook" or "all pages under the space home".
Syntax
ancestor = <contentId>
ancestor in (<contentId>, <contentId>)
Arguments
| Argument | What it does | Optional |
|---|---|---|
contentId | The numeric id of the page, as it appears in the page URL. A title does not work. | yes |
Works with
- Operators: =, !=, IN, NOT IN
- Functions: none listed in the documentation; recentlyViewedContent() ran with IN
- Not with: ~, !~, >, >=, <, <=
Examples
ancestor = 32964613 AND type = pageEvery page under a handbook, whatever its depth. Use it to count or audit a documentation tree.
Run on Confluence Cloud on .
ancestor = 32964613 AND title ~ "runbook"Runbooks inside one section only, instead of across the whole space.
Run on Confluence Cloud on .
ancestor in (32964613, 655541) AND type = pagePages under either of two parents in one query, written with IN.
Run on Confluence Cloud on .
ancestor = 655541 AND parent != 655541 AND type = pagePages below the space home that are not its direct children, so the deeper levels only.
Run on Confluence Cloud on .
ancestor = 32964613 AND lastmodified >= startOfWeek() AND type = page ORDER BY lastmodified DESCWhat changed this week inside one section, newest first.
Run on Confluence Cloud on .
ancestor not in (32964613) AND space = SD AND type = pageEvery page of a space except the handbook subtree. Useful to exclude one area from a report.
Run on Confluence Cloud on .
Pitfalls
- ancestor is wider than parent. With the handbook page 32964613 under the space home 655541, its child pages match both
ancestor = 32964613andancestor = 655541, but onlyparent = 32964613(checked on Confluence Cloud, November 2026). - It only takes ids.
ancestor = "Company handbook"fails with: Can't parse as a ContentId. An id that does not exist, such asancestor = 999999999, does not fail: it returns no results. - The page you name is not in its own result.
ancestor = 32964613 AND id = 32964613returns nothing: the query lists what is below the handbook, not the handbook itself (checked on Confluence Cloud, November 2026). - Comparison operators are refused:
ancestor > 655541returns Operator '>' is not supported for field 'ancestor'. Supported operators are : =, !=, IN, NOT IN.