Advanced Searching using CQL

CQL keywords reference

What is a keyword in CQL

A keyword in CQL is a word or phrase that:

  • Joins two or more clauses together to form a complex CQL query.
  • Alters the logic of one or more clauses.
  • Alters the logic of operators.
  • Has an explicit definition in a CQL query.
  • Performs a specific function that alters the results of a CQL query.

See the detailed examples for each keyword next.

AND

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

Note: to control the order in which clauses are executed, you can use parentheses.

Examples
  • Find all blogposts with the label "performance".

    1
    2
    label = "performance" and type = "blogpost"
    
  • Find all pages created by jsmith in the DEV space.

    1
    2
    type = page and creator = jsmith and space = DEV
    
  • Find all content that mentions jsmith but was not created by jsmith.

    1
    2
    mention = jsmith and creator != jsmith
    

OR

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

Note: to control the order in which clauses are executed, you can use parentheses. Also see 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 (that is a query made up of more than one clause) using parentheses, allowing you to refine your search.

(Note: also see NOT EQUALS ("!="), DOES NOT CONTAIN ("!~") and 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 jsmith ordered by created, then title

    1
    2
    creator = jsmith order by created, title asc
    

Rate this page: