Yet Another Alfresco Limitation for the JavaScript API – Lucene Search

Post date: Jun 18, 2012 9:10:09 AM

In case an application is already in production and a significant amount of content exists already but the model behind the content is changed due to change requests, then the general procedure is to locate the information to be updated with a Lucene query and to supply the required values for the newly added property in the model.

When this is performed under Alfresco 3.x using the JavaScript API however, if the Lucene results exceed 1000 records, not all of them are returned and when issuing a save() operation using the NodeScript API on each record, the strange situation of a random update of content is encountered.

Changing the “system.acl.maxPermissionCheckTimeMillis” and “system.acl.maxPermissionChecks” resource limits spent on individual searches inside repository.properties does not really help, so, a solution for this case is to:

1) Avoid JavaScript for such purposes and use the Java API which exposes the setLimit() and setLimitBy() methods on the SearchParameters class.

2) Use JavaScript and restrict the initial Lucene search issuing a condition based on the previous one and additionally including the new model property which would not have the desired value yet. This restricted query is to be run iteratively until all nodes are updated.