CQL keywords

A keyword in CQL is a word or phrase that:

  • joins two or more clauses together to form a complex CQL query, or
  • alters the logic of one or more clauses, or
  • alters the logic of operators, or
  • has an explicit definition in a CQL query, or
  • performs a specific function that alters the results of a CQL query.

AND

Used to combine multiple clauses, allowing you to refine your search.

You can use [parentheses](/cloud/confluence/advanced-searching-using-cql#setting-precedence-of-operators) to control the order in which clauses are executed.

Examples

  • Find all blogposts with the label "performance"

    1
    2
    label = "performance" and type = "blogpost"
    
  • Find all pages created by the user with the accountId 99:27935d01-XXXX-XXXX-XXXX-a9b8d3b2ae2e in the DEV space

    1
    2
    type = page and creator = "99:27935d01-XXXX-XXXX-XXXX-a9b8d3b2ae2e" and space = DEV
    
  • Find all content that mentions the user with the accountId 99:27935d01-XXXX-XXXX-XXXX-a9b8d3b2ae2e but was not created by the same user

    1
    2
    mention = "99:27935d01-XXXX-XXXX-XXXX-a9b8d3b2ae2e" and creator != "99:27935d01-XXXX-XXXX-XXXX-a9b8d3b2ae2e"
    

OR

Used to combine multiple clauses, allowing you to expand your search.

You can use [parentheses](/cloud/confluence/advanced-searching-using-cql#operator-reference) to control the order in which clauses are executed. Also see [IN](/cloud/confluence/cql-operators#in), which can be a more convenient way to search for multiple values of a field.

Examples

  • Find all content in the IDEAS space or with the label idea

    1
    2
    space = IDEAS or label = idea
    
  • Find all content last modified before the start of the year or with the label needs_review

    1
    2
    lastModified < startOfYear() or label = needs_review
    

NOT

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.

Also see [NOT EQUALS](/cloud/confluence/cql-operators#not-equals) ("!="), [DOES NOT CONTAIN](/cloud/confluence/cql-operators#does-not-contain) ("!~") and [NOT IN](/cloud/confluence/cql-operators#not-in).)

Examples

  • Find all pages with the "cql" label that aren't in the dev space

    1
    2
    label = cql and not space = dev 
    

ORDER BY

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.

Examples

  • Find content in the DEV space ordered by creation date

    1
    2
    space = DEV order by created
    
  • Find content in the DEV space ordered by creation date with the newest first, then title

    1
    2
    space = DEV order by created desc, title
    
  • Find pages created by the user with the accountId 99:27935d01-XXXX-XXXX-XXXX-a9b8d3b2ae2e ordered by space, then title

    1
    2
    creator = "99:27935d01-XXXX-XXXX-XXXX-a9b8d3b2ae2e" order by space, title asc
    

Rate this page: