Getting total count of an object search
Various options can be passed to the searches. These options are supported in the CE
query SQL syntax.
The COUNT_LIMIT option allows the totalCount field, a member of pageInfo, to be returned with a
value. The option itself indicates the limit of matching items to be counted beyond the result items
being returned as the current page of results. Refer to the Content Engine documentation for further
details about this option. The following example involves a search for
documents:
{
documents(
repositoryIdentifier:"OS1"
from:"Document"
where:"[DateCreated] > 20180815T070000Z AND [IsCurrentVersion] = True"
orderBy:"DocumentTitle"
options:"COUNT_LIMIT 5000"
pageSize:20
) {
documents {
dateCreated
id
name
majorVersionNumber
minorVersionNumber
mimeType
}
pageInfo {
token
totalCount
}
}
}
With the previous search example, the totalCount field will be returned with the
total number of matching items, up to the count supplied as the COUNT_LIMIT value.
If COUNT_LIMIT is reached before all matching items have been counted,
totalCount will be returned as a negative value to indicate this.