CQL field
space in CQL (Confluence): syntax and examples
The space field restricts results to content that lives in a given space, identified by its space key. Almost every real CQL query starts with it, because a site-wide search mixes team spaces with personal ones. It also has sub-fields that filter on the space's key, title, type and category.
Syntax
space = KEY
space in (KEY1, KEY2)
space.type = personal
Arguments
| Argument | What it does |
|---|---|
KEY | The space key, such as SD. Case does not matter. Wrap it in double quotes when it starts with a digit or a tilde. |
space.key | Sub-field that matches the key. Accepts =, !=, IN and NOT IN. |
space.title | Sub-field that matches the space name. Use ~ or !~. |
space.type | Sub-field for the kind of space, for example personal or global. |
space.category | Sub-field for the space category. |
Works with
- Operators: =, !=, IN, NOT IN. The field reference also lists ~ and !~ as unsupported, but both ran (see the pitfalls)
- Functions: favouriteSpaces(), recentlyViewedSpaces()
- Not with: >, >=, <, <=
Examples
space = SD AND type = page ORDER BY lastmodified DESCLists the pages of one space, most recently edited first. A good start for any clean-up or review of a team space.
Run on Confluence Cloud on .
space in ("3C", "4C")Searches two spaces at once when their keys start with a digit, which is why the keys are quoted.
Run on Confluence Cloud on .
space.type = personal AND type = attachmentFinds files that sit in personal spaces, where nobody else is likely to look for them.
Run on Confluence Cloud on .
space.title ~ "Software" AND type = pagePicks spaces by a word in their name when you do not remember the key.
Run on Confluence Cloud on .
space != SDShows everything outside your main space, which is mostly personal-space content.
Run on Confluence Cloud on .
space.key in (SD, "3C") AND type = pageCombines a plain key and a quoted key in one list, using the key sub-field.
Run on Confluence Cloud on .
Pitfalls
- A key that starts with a digit must be quoted.
space = 3Cfails with "Unrecognised clause at : C", whilespace = "3C"runs. Personal space keys start with a tilde and are long, so quote them too:space = ~abcfails with "Expecting a value for operator '=' after field 'space' but got '~'". spacecompares keys, not names.space = "Software Development"runs and finds nothing. For the name usespace.title ~ "Software".space.title = "Software"andspace.key ~ "SD"do not work: the first gives "Could not parse cql", the second "Operator '~' is not supported for field 'space.key'".- The doc table says
space ~andspace !~are unsupported.space ~ "Software"andspace !~ "Software"both run and match the space name (checked on Confluence Cloud, November 2026). The sub-fieldspace.title ~gives the same match, so prefer it in filters you keep. - A query on
space = SDalone also returns the space itself as a result, next to its pages, comments and attachments. AddAND type != spaceorAND type = pagewhen you only want content.
Questions and answers
How do I find the key of a space?
It is the short code in the space URL, for example /spaces/SD/overview. The key is also listed in space settings.
Can I search every space except one?
Yes. Use space != SD or space not in (SD, ENG).