Skip to content

Instantly share code, notes, and snippets.

@cmlewis
Created September 27, 2017 12:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cmlewis/066c512a0f333ce1b0aad4d389ad8426 to your computer and use it in GitHub Desktop.
Save cmlewis/066c512a0f333ce1b0aad4d389ad8426 to your computer and use it in GitHub Desktop.
Get the total number of objects (files or folders) of a particular type in Alfresco. This helps bypass Alfresco's query limit of 1000.
// Get the total number of objects of one type.
// This accounts for the query limits in Alfresco (which is 1000 results by default)
var query = 'TYPE:"myco:document"';
var totalNumOfDocs = 0;
do {
var page = {
maxItems: 1000,
skipCount: totalNumOfDocs
};
var def = {
query: query,
store: "workspace://SpacesStore",
language: "lucene",
page: page
};
var nodes = search.query(def);
//logger.log(nodes.length);
totalNumOfDocs += nodes.length;
} while (nodes.length > 0);
logger.log("TOTAL NUMBER OF DOCS: " + totalNumOfDocs);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment