In this page

CQL query samples

The following samples demonstrate how to use the CQL fields provided by Better Content Archiving in combination with other fields in frequent searches.

Status

Contents in the status "Expired":

arch.status = "Expired"

Contents in the status #123:

arch.status.id = 123

(Searching by status ID is less readable than by name, but it is stable if the status is renamed. On the other hand, a status with a specific name can be re-created any time. Which one is optimal depends on your use case. To figure out the ID of a status, see the value of the "arch.status.id" CQL field for any content in that status through the Status details → CQL fields tab.)

Contents in the space "Foo" and in the status "Expired":

space = "Foo" and arch.status = "Expired"

Contents in the spaces "Foo" or "Bar" and in the status #123:

space in ("Foo","Bar") and arch.status.id = 123

(Searching by status ID is less readable than by name, but it is stable if the status is renamed. On the other hand, a status with a specific name can be re-created any time. Which one is optimal depends on your use case. To figure out the ID of a status, see the value of the "arch.status.id" CQL field for any content in that status through the Status details → CQL fields tab.)

Contents with their status changed in the last 24 hours:

arch.status.changedOn > now("-24h")

Contents in the status "To archive" and changed to that this week:

arch.status = "To archive" and arch.status.changedOn > startOfWeek()

Contents in the status "Expired" and changed to that more than 10 days ago:

arch.status = "Expired" and arch.status.changedOn < now("-10d")

Contents with previous status "Up-to-date":

arch.previousStatus = "Up-to-date"

Contents transitioned from status "Expired" to "Up-to-date" in the last 7 days:

arch.previousStatus = "Expired" and arch.status = "Up-to-date" and arch.status.changedOn > now("-7d")

Contents in the spaces "Foo" or "Bar" and their current status changed from status #123:

space in ("Foo","Bar") and arch.previousStatus.id = 123

(Searching by status ID is less readable than by name, but it is stable if the status is renamed. On the other hand, a status with a specific name can be re-created any time. Which one is optimal depends on your use case. To figure out the ID of a status, see the value of the "arch.status.id" CQL field for any content in that status through the Status details → CQL fields tab.)

Views (view analytics)

Contents not viewed in the last 100 days:

arch.event.lastViewedOn < now("-100d")

Contents last viewed by me:

arch.event.lastViewedBy = currentUser()

Contents last viewed by a specific user:

arch.event.lastViewedBy = "123abcde95673300697be2ba"

(The alphanumeric string is the Atlassian account ID of the user. How to figure out?)

Updates (update analytics)

Contents not updated in the last 50 days:

arch.event.lastUpdatedOn < now("-50d")

Contents last updated by me:

arch.event.lastUpdatedBy = currentUser()

Contents last updated by a specific user:

arch.event.lastUpdatedBy = "123abcde95673300697be2ba"

(The alphanumeric string is the Atlassian account ID of the user. How to figure out?)

Owners

Contents that have owners, either directly or through inheritance:

arch.anyOwner.count > 0

Contents that have no owner:

type in (page,blogpost) and not arch.anyOwner.count > 0

Contents owned by me, either directly or through inheritance:

arch.anyOwner in (currentUser())

Contents owned by a specific user, either directly or through inheritance:

arch.anyOwner in ("123abcde95673300697be2ba")

(The alphanumeric string is the Atlassian account ID of the user. How to figure out?)

Contents that have owners changed this week:

arch.anyOwner.count > 0 and arch.anyOwner.setOn > startOfWeek()

Contents owned by a specific user directly:

arch.directOwner in ("123abcde95673300697be2ba")

(The alphanumeric string is the Atlassian account ID of the user. How to figure out?)

Contents owned directly by exactly 2 users:

arch.directOwner.count = 2

Contents with direct owners set this week:

arch.directOwner.setOn > startOfWeek()

Contents owned by a specific user through inheritance:

arch.inheritedOwner in ("123abcde95673300697be2ba")

(The alphanumeric string is the Atlassian account ID of the user. How to figure out?)

Contents owned through inheritance by exactly 2 users:

arch.inheritedOwner.count = 2

Contents owned through inheritance set this week:

arch.inheritedOwner.setOn > startOfWeek()

Contents owned by a specific user:

arch.owner = "123abcde95673300697be2ba"

(The alphanumeric string is the Atlassian account ID of the user. How to figure out?)

Contents owned by at least 2 users:

arch.owner.count >= 2

Contents owned by a specific user with ownership inherited by descendants, set this week:

arch.treeOwner = "123abcde95673300697be2ba" and arch.treeOwner.setOn > startOfWeek()

(The alphanumeric string is the Atlassian account ID of the user. How to figure out?)

Contents with owners, both those that are and aren't inherited by descendants, set by me:

arch.owner.setBy = currentUser() or arch.treeOwner.setBy = currentUser()

Roots of content trees with tree owners (that are inherited by descendants):

arch.treeOwner.count > 0

Contents with owners, that are not inherited by descendants, set today:

arch.owner.setOn > startOfDay()

Roots of content trees with tree owners (that are inherited by descendants) set this week:

arch.treeOwner.setBy = "123abcde95673300697be2ba"

(The alphanumeric string is the Atlassian account ID of the user. How to figure out?)

Expiration

Contents with an expiration date:

arch.expirationDate.setOn <= now()

(This actual date field cannot be tested for emptiness in CQL. Therefore, this query tests timestamp when the actual date was set.)

Contents without an expiration date:

type in (page,blogpost) and not arch.expirationDate.setOn <= now()

(The otherwise useless clause on the "type" field is needed because a negative expression cannot be the first clause in CQL.)

Contents with a passed expiration date:

arch.expirationDate < now()

Contents with an expiration date inherited by descendants:

arch.expirationDate.inherited = "true"

Contents with an expiration date set by me:

arch.expirationDate.setBy = currentUser()

Contents with an expiration date set by a specific user:

arch.expirationDate.setBy = "123abcde95673300697be2ba"

(The alphanumeric string is the Atlassian account ID of the user. How to figure out?)

Contents with an expiration date set today:

arch.expirationDate.setOn > startOfDay()

Archiving

Contents with an archiving date:

arch.archivingDate.setOn <= now()

(This actual date field cannot be tested for emptiness in CQL. Therefore, this query tests timestamp when the actual date was set.)

Contents without an archiving date:

type in (page,blogpost) and not arch.archivingDate.setOn <= now()

(The otherwise useless clause on the "type" field is needed because a negative expression cannot be the first clause in CQL.)

Contents with a passed archiving date:

arch.archivingDate < now()

Contents with an archiving date inherited by descendants:

arch.archivingDate.inherited = "true"

Contents with archiving date set by me:

arch.archivingDate.setBy = currentUser()

Contents with archiving date set today:

arch.archivingDate.setOn >= startOfDay()

Contents archived yesterday:

arch.event.archivedOn > startOfDay("-1d") and arch.event.archivedOn < startOfDay()

(At the "Search In" checkboxes, check the "Archived pages" option for this query, otherwise it will not find anything!)

Contents archived this week:

arch.event.archivedOn > startOfWeek()

(At the "Search In" checkboxes, check the "Archived pages" option for this query, otherwise it will not find anything!)

Excluded contents

Contents excluded from content lifecycle management:

arch.exclusion = "true"

Contents excluded from content lifecycle management together with descendants:

arch.exclusion.inherited = "true"

Contents excluded by me:

arch.exclusion.setBy = currentUser()

Contents excluded today:

arch.exclusion.setOn >= startOfDay()

Contents in excluded spaces:

arch.inExcludedSpace = "true"

(Note: schemes only work with contents in included spaces.)

Questions?

Ask us any time.