Created
September 27, 2017 12:42
-
-
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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