Going Stellar

Home/CQL reference

CQL field

label in CQL (Confluence): syntax and examples

The label field matches content that carries a given label. Use it to pull a tagged set of pages, such as everything labelled for review, or to exclude labelled pages from a list. It takes exact label names, not patterns.

Syntax

label = value
label in (value1, value2)
label not in (value1, value2)

Arguments

ArgumentWhat it does
valueA label name. Wrap it in double quotes when it contains a hyphen, a space or other punctuation.

Works with

  • Operators: =, !=, IN, NOT IN
  • Functions: none
  • Not with: ~, !~, >, >=, <, <=

Examples

label = "meeting-notes"

Collects every page tagged as meeting notes. The label has a hyphen, so it is quoted.

Run on Confluence Cloud on .

label in ("draft", "review") AND type = page AND space = SD

Shows pages that are still in draft or waiting for review in one space.

Run on Confluence Cloud on .

label not in (draft, review)

Keeps only content that carries neither label, a quick list of finished work.

Run on Confluence Cloud on .

label != "draft" AND type = page AND space = SD

Lists the pages of a space that are not marked as draft.

Run on Confluence Cloud on .

label in (draft) AND lastmodified < now("-4w")

Finds drafts nobody has touched for four weeks, good candidates for a reminder.

Run on Confluence Cloud on .

Pitfalls

  • A hyphen needs quotes. label = meeting-notes fails with "Could not parse cql", label = "meeting-notes" runs. Plain words such as draft work with or without quotes, and a quoted value gives the same query as the unquoted one.
  • label ~ "draft" fails with "Operator '~' is not supported for field 'label'". To match several labels list them: label in (draft, review). To match a label prefix, search the text field instead.
  • A query cannot start with NOT. not label = draft and NOT label in (draft) fail with "Could not parse cql"; type = page AND NOT label = draft runs. Writing label != draft avoids the problem.
  • There is no IS EMPTY test: label is empty fails with "Could not parse cql". A prefixed form such as label = global:finished fails the same way. Whether label case is ignored is not covered by the docs, so match the case you see in the page.

Sources

  1. CQL fields (Atlassian Developer, Confluence Cloud)

Markdown version · All CQL pages