The instructions on this page describe how to define and execute a search using the advanced search capabilities of the Confluence REST API.
An advanced search allows you to use structured queries to search for content in Confluence. Your search results will take the same form as the Content model returned by the Content REST API.
When you perform an advanced search, you are using the Confluence Query Language (CQL).
A simple query in CQL (also known as a 'clause') consists of a field, followed by an operator, followed by one or more values or functions. For example, the following simple query will find all content in the "TEST" space. It uses the Space field, the EQUALS operator, and the value ("TEST"
.)
1 2space = "TEST"
It is not possible to compare two fields.
The Content API REST Resource now supports CQL as a query parameter to filter the list of returned content.
1 2https://your-domain.atlassian.net/wiki/rest/api/content/search?cql=space=TEST
To perform an advanced search:
You can use the CONTAINS operator to use Lucene's text-searching features when performing searches on these fields:
For details, please see the page on Performing text searches.
You can use parentheses in complex CQL statements to enforce the precedence of operators.
For example, if you want to find all pages in the Developer space as well as all blog posts created by the user with accountId 99:27935d01-XXXX-XXXX-XXXX-a9b8d3b2ae2e
, you can use parentheses to enforce the precedence of the boolean operators in your query. For example:
1 2(type=page and Space=DEV) OR (creator="99:27935d01-XXXX-XXXX-XXXX-a9b8d3b2ae2e" and type=blogpost)
You can also use parentheses to group clauses, so that you can apply the NOT operator to the group.
A keyword in CQL is a word or phrase that:
List of keywords:
Used to combine multiple clauses, allowing you to refine your search.
Find all blogposts with the label "performance"
1 2label = "performance" and type = "blogpost"
Find all pages created in the DEV space by the user with accountId 99:27935d01-XXXX-XXXX-XXXX-a9b8d3b2ae2e
1 2type = page and creator = "99:27935d01-XXXX-XXXX-XXXX-a9b8d3b2ae2e" and space = DEV
Find all content that mentions the user with accountId 99:27935d01-XXXX-XXXX-XXXX-a9b8d3b2ae2e
, but was not created by the same user
1 2mention = "99:27935d01-XXXX-XXXX-XXXX-a9b8d3b2ae2e" and creator != "99:27935d01-XXXX-XXXX-XXXX-a9b8d3b2ae2e"
Used to combine multiple clauses, allowing you to expand your search.
Find all content in the IDEAS space or with the label idea
1 2space = IDEAS or label = idea
Find all content last modified before the start of the year or with the label needs_review
1 2lastModified < startOfYear() or label = needs_review
Used to negate individual clauses or a complex CQL query (a query made up of more than one clause) using parentheses, allowing you to refine your search.
Find all pages with the "cql" label that aren't in the dev space
1 2label = cql and not space = dev
Used to specify the fields by whose values the search results will be sorted.
By default, the field's own sorting order will be used. You can override this by specifying ascending order ("asc
") or descending order ("desc
").
Not all fields support Ordering. Generally, ordering is not supported where a piece of content can have multiple values for a field, for instance ordering is not supported on labels.
Find content in the DEV space ordered by creation date
1 2space = DEV order by created
Find content in the DEV space ordered by creation date with the newest first, then title
1 2space = DEV order by created desc, title
Find pages created by the user with accountId 99:27935d01-XXXX-XXXX-XXXX-a9b8d3b2ae2e
, ordered by space, then title
1 2creator = "99:27935d01-XXXX-XXXX-XXXX-a9b8d3b2ae2e" order by space, title asc
An operator in CQL is one or more symbols or words which compares the value of a field on its left with one or more values (or functions) on its right, such that only true results are retrieved by the clause. Some operators may use the NOT keyword.
List of operators:
The "=
" operator is used to search for content where the value of the specified field exactly matches the specified value (cannot be used with text fields; see the CONTAINS operator instead.)
To find content where the value of a specified field exactly matches multiple values, use multiple "=
" statements with the AND operator.
Find all content that was created by the user with accountId 99:27935d01-XXXX-XXXX-XXXX-a9b8d3b2ae2e
1 2creator = "99:27935d01-XXXX-XXXX-XXXX-a9b8d3b2ae2e"
Find all content that has the title "Advanced Searching"
1 2title = "\"Advanced Searching\""
The "!=
" operator is used to search for content where the value of the specified field does not match the specified value. (Note: cannot be used with text fields; see the DOES NOT MATCH ("!~
") operator instead.)
Currently a negative expression cannot be the first clause in a CQL statement
Find all content in the DEV space that was created by someone other than the user with accountId 99:27935d01-XXXX-XXXX-XXXX-a9b8d3b2ae2e
1 2space = DEV and not creator = "99:27935d01-XXXX-XXXX-XXXX-a9b8d3b2ae2e"
or:
1 2space = DEV and creator != "99:27935d01-XXXX-XXXX-XXXX-a9b8d3b2ae2e"
Find all content that was created by me but doesn't mention me
1 2creator = currentUser() and mention != currentUser()
The ">
" operator is used to search for content where the value of the specified field is greater than the specified value. Cannot be used with text fields.
Note that the ">
" operator can only be used with fields which support range operators (e.g. date fields and numeric fields). To see a field's supported operators, check the individual field reference.
Find all content created in the last 4 weeks
1 2created > now("-4w")
Find all attachments last modified since the start of the month
1 2created > startOfMonth() and type = attachment
The ">=
" operator is used to search for content where the value of the specified field is greater than or equal to the specified value. Cannot be used with text fields.
Note that the ">=
" operator can only be used with fields which support range operators (e.g. date fields). To see a field's supported operators, check the individual field reference.
Find all content created on or after 31/12/2008:
1 2created >= "2008/12/31"
The "<
" operator is used to search for content where the value of the specified field is less than the specified value. Cannot be used with text fields.
Note that the "<
" operator can only be used with fields which support range operators (e.g. date fields). To see a field's supported operators, check the individual field reference.
Find all pages lastModified before the start of the year
1 2lastModified < startOfYear() and type = page
The "<=
" operator is used to search for content where the value of the specified field is less than or equal to than the specified value. Cannot be used with text fields.
Note that the "<=
" operator can only be used with fields which support range operators (e.g. date fields). To see a field's supported operators, check the individual field reference.
Find blogposts created in the since the start of the fortnight
1 2created >= startOfWeek("-1w") and type = blogpost
The "IN
" operator is used to search for content where the value of the specified field is one of multiple specified values. The values are specified as a comma-delimited list, surrounded by parentheses.
Using "IN
" is equivalent to using multiple EQUALS (=)
statements with the OR keyword, but is shorter and more convenient. That is, typing creator IN ("99:27935d01-XXXX-XXXX-XXXX-a9b8d3b2ae2e", "48293:5s04-XXXX-XXXX-XXXX-d7a9b9d8c9f01", "2223:48d-3a-XXXX-XXXX-XXXX-8d9dd0e98as7")
is the same as typing creator = "99:27935d01-XXXX-XXXX-XXXX-a9b8d3b2ae2e" OR creator = "48293:5s04-XXXX-XXXX-XXXX-d7a9b9d8c9f01" OR creator = "2223:48d-3a-XXXX-XXXX-XXXX-8d9dd0e98as7"
.
Find all content that mentions any of the users with the accountIds 99:27935d01-XXXX-XXXX-XXXX-a9b8d3b2ae2e
,48293:5s04-XXXX-XXXX-XXXX-d7a9b9d8c9f01
, or 2223:48d-3a-XXXX-XXXX-XXXX-8d9dd0e98as7
1 2mention in ("99:27935d01-XXXX-XXXX-XXXX-a9b8d3b2ae2e", "48293:5s04-XXXX-XXXX-XXXX-d7a9b9d8c9f01", "2223:48d-3a-XXXX-XXXX-XXXX-8d9dd0e98as7")
Find all content where the creator or contributor is either the user with the accountId 99:27935d01-XXXX-XXXX-XXXX-a9b8d3b2ae2e
or the user with the accountId 48293:5s04-XXXX-XXXX-XXXX-d7a9b9d8c9f01
1 2creator in ("99:27935d01-XXXX-XXXX-XXXX-a9b8d3b2ae2e", "48293:5s04-XXXX-XXXX-XXXX-d7a9b9d8c9f01") or contributor in ("99:27935d01-XXXX-XXXX-XXXX-a9b8d3b2ae2e", "48293:5s04-XXXX-XXXX-XXXX-d7a9b9d8c9f01")
The "NOT IN
" operator is used to search for content where the value of the specified field is not one of multiple specified values.
Using "NOT IN
" is equivalent to using multiple NOT_EQUALS (!=)
statements, but is shorter and more convenient. That is, typing creator NOT IN ("99:27935d01-XXXX-XXXX-XXXX-a9b8d3b2ae2e", "48293:5s04-XXXX-XXXX-XXXX-d7a9b9d8c9f01", "2223:48d-3a-XXXX-XXXX-XXXX-8d9dd0e98as7")
is the same as typing creator != "99:27935d01-XXXX-XXXX-XXXX-a9b8d3b2ae2e" AND creator != "48293:5s04-XXXX-XXXX-XXXX-d7a9b9d8c9f01" AND creator != "2223:48d-3a-XXXX-XXXX-XXXX-8d9dd0e98as7"
.
Find all content where the creator is someone other than the users with the accountIds 99:27935d01-XXXX-XXXX-XXXX-a9b8d3b2ae2e
,48293:5s04-XXXX-XXXX-XXXX-d7a9b9d8c9f01
, or 2223:48d-3a-XXXX-XXXX-XXXX-8d9dd0e98as7
1 2space = DEV and creator not in ("99:27935d01-XXXX-XXXX-XXXX-a9b8d3b2ae2e", "48293:5s04-XXXX-XXXX-XXXX-d7a9b9d8c9f01", "2223:48d-3a-XXXX-XXXX-XXXX-8d9dd0e98as7")
The "~
" operator is used to search for content where the value of the specified field matches the specified value (either an exact match or a "fuzzy" match -- see examples below). The "~" operator can only be used with text fields, for example:
Find content created by users with a full name (depending on profile visibility) like alana
1 2creator.fullname ~ "alana"
Find all content where the title contains the word "win" (or simple derivatives of that word, such as "wins"):
1 2title ~ win
Find all content where the title contains a wild-card match for the word "win":
1 2title ~ "win*"
Find all content where the text contains the exact phrase "advanced search":
1 2text ~ "\"advanced search\""
The "!~
" operator is used to search for content where the value of the specified field is not a "fuzzy" match for the specified value. The "!~" operator can only be used with text fields, for example:
Find all content where the title does not contain the word "run" (or derivatives of that word, such as "running" or "ran"):
1 2space = DEV and title !~ run
A field in CQL is a word that represents an indexed property of content in Confluence. In a clause, a field is followed by an operator, which in turn is followed by one or more values (or functions). The operator compares the value of the field with one or more values or functions on the right, such that only true results are retrieved by the clause.
CQL input queries submitted through the /wiki/rest/api/search
endpoint no longer support user-specific fields like user
, user.fullname
, user.accountid
, and user.userkey
.
CQL input queries submitted through the /wiki/rest/api/search/user
endpoint only support user-specific fields like user
, user.fullname
, user.accountid
, and user.userkey
.
See this deprecation notice for more details.
List of fields:
Search for all pages that are descendants of a given ancestor page. This includes direct child pages and their descendants. It is more general than the parent field.
1 2ancestor
CONTENT
= | != | ~ | !~ | > | >= | < | <= | IN | NOT IN |
---|---|---|---|---|---|---|---|---|---|
yes | yes | no | no | no | no | no | no | yes | yes |
None
Find all descendant pages with a given ancestor page
1 2ancestor = 123
Find descendants of a group of ancestor pages
1 2ancestor in (123, 456, 789)
Search for content that have a given content ID. This is an alias of the ID field.
1 2content
CONTENT
= | != | ~ | !~ | > | >= | < | <= | IN | NOT IN |
---|---|---|---|---|---|---|---|---|---|
yes | yes | no | no | no | no | no | no | yes | yes |
None
Find content with a given content id
1 2content = 123
Find content in a set of content ids
1 2content in (123, 223, 323)
Search for content that was created on, before or after a particular date (or date range).
Use one of the following formats:
"yyyy/MM/dd HH:mm"
"yyyy-MM-dd HH:mm"
"yyyy/MM/dd"
"yyyy-MM-dd"
1 2created
DATE
= | != | ~ | !~ | > | >= | < | <= | IN | NOT IN |
---|---|---|---|---|---|---|---|---|---|
yes | yes | no | no | yes | yes | yes | yes | no | no |
Find content created after the 1st September 2014
1 2created > 2014/09/01
Find content created in the last 4 weeks
1 2created >= now("-4w")
Search for content that was created by a particular user. You can search by the user's accountId.
1 2creator
USER
= | != | ~ | !~ | > | >= | < | <= | IN | NOT IN |
---|---|---|---|---|---|---|---|---|---|
yes | yes | no | no | no | no | no | no | yes | yes |
Find content created by the user with the accountId 99:27935d01-XXXX-XXXX-XXXX-a9b8d3b2ae2e
1 2creator = "99:27935d01-XXXX-XXXX-XXXX-a9b8d3b2ae2e"
Find content created by the user with the accountId 99:27935d01-XXXX-XXXX-XXXX-a9b8d3b2ae2e
or the user with the accountId 48293:5s04-XXXX-XXXX-XXXX-d7a9b9d8c9f01
1 2creator in ("99:27935d01-XXXX-XXXX-XXXX-a9b8d3b2ae2e", "48293:5s04-XXXX-XXXX-XXXX-d7a9b9d8c9f01")
Search for content that was created or edited by a particular user. You can search by the user's accountId.
1 2contributor
USER
= | != | ~ | !~ | > | >= | < | <= | IN | NOT IN |
---|---|---|---|---|---|---|---|---|---|
yes | yes | no | no | no | no | no | no | yes | yes |
Find content created by 99:27935d01-XXXX-XXXX-XXXX-a9b8d3b2ae2e
1 2contributor = "99:27935d01-XXXX-XXXX-XXXX-a9b8d3b2ae2e"
Find content created by the user with the accountId 99:27935d01-XXXX-XXXX-XXXX-a9b8d3b2ae2e
or the user with the accountId 48293:5s04-XXXX-XXXX-XXXX-d7a9b9d8c9f01
1 2contributor in ("99:27935d01-XXXX-XXXX-XXXX-a9b8d3b2ae2e", "48293:5s04-XXXX-XXXX-XXXX-d7a9b9d8c9f01")
Search for content that was favorited by a particular user. You can search by the user's accountId.
Due to security restrictions you are only allowed to filter on the logged in user's favorites. This field is available in both British and American spellings.
1 2favourite
USER
= | != | ~ | !~ | > | >= | < | <= | IN | NOT IN |
---|---|---|---|---|---|---|---|---|---|
yes | yes | no | no | no | no | no | no | yes | yes |
Find content that is favorited by the current user
1 2favourite = currentUser()
Find content favorited by the user with the accountId 99:27935d01-XXXX-XXXX-XXXX-a9b8d3b2ae2e
, where the same user is also the logged-in user
1 2favourite = "99:27935d01-XXXX-XXXX-XXXX-a9b8d3b2ae2e"
Search for content that have a given content ID.
1 2id
CONTENT
= | != | ~ | !~ | > | >= | < | <= | IN | NOT IN |
---|---|---|---|---|---|---|---|---|---|
yes | yes | no | no | no | no | no | no | yes | yes |
None
Find content with the ID 123
1 2id = 123
Find content in a set of content IDs
1 2id in (123, 223, 323)
Search for content that has a particular label
1 2label
STRING
= | != | ~ | !~ | > | >= | < | <= | IN | NOT IN |
---|---|---|---|---|---|---|---|---|---|
yes | yes | no | no | no | no | no | no | yes | yes |
None
Find content that has the label finished
1 2label = finished
Find content that doesn't have the label draft or review
1 2label not in (draft, review)
Search for content that was last modified on, before, or after a particular date (or date range).
The search results will be relative to your configured time zone (which is by default the Confluence server's time zone)
Use one of the following formats:
"yyyy/MM/dd HH:mm"
"yyyy-MM-dd HH:mm"
"yyyy/MM/dd"
"yyyy-MM-dd"
1 2lastmodified
DATE
= | != | ~ | !~ | > | >= | < | <= | IN | NOT IN |
---|---|---|---|---|---|---|---|---|---|
yes | yes | no | no | yes | yes | yes | yes | no | no |
Find content that was last modified on 1st September 2014
1 2lastmodified = 2014-09-01
Find content that was last modified before the start of the year
1 2lastmodified < startOfYear()
Find content that was last modified on or after 1st September but before 9am on 3rd September 2014
1 2lastmodified >= 2014-09-01 and lastmodified < "2014-09-03 09:00"
Search for content that has an instance of the macro with the given name in the body of the content
1 2macro
STRING
= | != | ~ | !~ | > | >= | < | <= | IN | NOT IN |
---|---|---|---|---|---|---|---|---|---|
yes | yes | no | no | no | no | no | no | yes | yes |
None
Find content that has the Jira issue macro
1 2macro = jira
Find content that has Table of content macro or the widget macro
1 2macro in (toc, widget)
Search for content that mentions a particular user. You can search by the user's accountId.
1 2mention
USER
= | != | ~ | !~ | > | >= | < | <= | IN | NOT IN |
---|---|---|---|---|---|---|---|---|---|
yes | yes | no | no | no | no | no | no | yes | yes |
Find content that mentions the user with the accountId 99:27935d01-XXXX-XXXX-XXXX-a9b8d3b2ae2e
or the user with the accountId 48293:5s04-XXXX-XXXX-XXXX-d7a9b9d8c9f01
1 2mention in ("99:27935d01-XXXX-XXXX-XXXX-a9b8d3b2ae2e", "48293:5s04-XXXX-XXXX-XXXX-d7a9b9d8c9f01")
Find content that mentions the user with the accountId 99:27935d01-XXXX-XXXX-XXXX-a9b8d3b2ae2e
1 2mention = "99:27935d01-XXXX-XXXX-XXXX-a9b8d3b2ae2e"
Search for child content of a particular parent page
1 2parent
CONTENT
= | != | ~ | !~ | > | >= | < | <= | IN | NOT IN |
---|---|---|---|---|---|---|---|---|---|
yes | yes | no | no | no | no | no | no | yes | yes |
None
Find child pages of a parent page with ID 123
1 2parent = 123
Search for content that is in a particular Space. You can search by the space's key.
1 2space
SPACE
= | != | ~ | !~ | > | >= | < | <= | IN | NOT IN |
---|---|---|---|---|---|---|---|---|---|
yes | yes | no | no | no | no | no | no | yes | yes |
None
Find content in the development space or the QA space
1 2space in (DEV, QA)
Find content in the development space
1 2space = DEV
This is a "master-field" that allows you to search for text across a number of other text fields. These are the same fields used by Confluence's search user interface.
1 2text
TEXT
= | != | ~ | !~ | > | >= | < | <= | IN | NOT IN |
---|---|---|---|---|---|---|---|---|---|
no | no | yes | yes | no | no | no | no | no | no |
None
Find content that contains the word Confluence
1 2text ~ Confluence
Find content in the development space
1 2space = DEV
Search for content by title, or with a title that contains particular text.
1 2title
TEXT
= | != | ~ | !~ | > | >= | < | <= | IN | NOT IN |
---|---|---|---|---|---|---|---|---|---|
yes | yes | yes | yes | no | no | no | no | yes | yes |
None
Find content with the title "Advanced Searching using CQL"
1 2title = "\"Advanced Searching using CQL\""
Find content where the title contains the exact phrase "Searching CQL" (i.e. a "fuzzy" match):
1 2title ~ "\"Searching CQL\""
Search for content of a particular type. Supported content types are:
1 2type
TYPE
= | != | ~ | !~ | > | >= | < | <= | IN | NOT IN |
---|---|---|---|---|---|---|---|---|---|
yes | yes | no | no | no | no | no | no | yes | yes |
None
Find blogposts or pages
1 2type IN (blogpost, page)
Find attachments
1 2type = attachment
Search for content that a particular user is watching. You can search by the user's accountId.
1 2watcher
USER
= | != | ~ | !~ | > | >= | < | <= | IN | NOT IN |
---|---|---|---|---|---|---|---|---|---|
yes | yes | no | no | no | no | no | no | yes | yes |
Search for content that you are watching:
1 2watcher = currentUser()
Search for content that the user with the accountId 99:27935d01-XXXX-XXXX-XXXX-a9b8d3b2ae2e
is watching:
1 2watcher = "99:27935d01-XXXX-XXXX-XXXX-a9b8d3b2ae2e"
Search for users visible to you. There are several ways to perform a user search.
1 2user
USER
= | != | ~ | !~ | > | >= | < | <= | IN | NOT IN |
---|---|---|---|---|---|---|---|---|---|
yes | no | no | no | no | no | no | no | yes | no |
Search for current user:
1 2user = currentUser()
Search for users by their accountIds:
1 2user = "99:27935d01-XXXX-XXXX-XXXX-a9b8d3b2ae2e" user in ("99:27935d01-XXXX-XXXX-XXXX-a9b8d3b2ae2e", "48293:5s04-XXXX-XXXX-XXXX-d7a9b9d8c9f01")
1 2user.fullname
USER
= | != | ~ | !~ | > | >= | < | <= | IN | NOT IN |
---|---|---|---|---|---|---|---|---|---|
no | no | yes | no | no | no | no | no | no | no |
None
Search for users by their partial full name or public name, whichever is visible:
1 2user.fullname ~ "John"
1 2user.accountid
USER
= | != | ~ | !~ | > | >= | < | <= | IN | NOT IN |
---|---|---|---|---|---|---|---|---|---|
yes | no | no | no | no | no | no | no | yes | no |
None
Search for users by their accountId:
1 2user.accountid = "99:27935d01-XXXX-XXXX-XXXX-a9b8d3b2ae2e"
Rate this page: