diff --git a/config/alfresco/repository.properties b/config/alfresco/repository.properties
index d13ebca9ea..3570218307 100644
--- a/config/alfresco/repository.properties
+++ b/config/alfresco/repository.properties
@@ -1206,4 +1206,7 @@ system.upgradePasswordHash.jobQueryRange=10000
system.upgradePasswordHash.jobThreadCount=4
system.upgradePasswordHash.jobCronExpression=* * * * * ? 2099
-system.api.discovery.enabled=true
\ No newline at end of file
+system.api.discovery.enabled=true
+
+# Maximum query size for category/tag fetch when not explicitly set by paging parameters
+category.queryFetchSize=5000
\ No newline at end of file
diff --git a/config/alfresco/subsystems/Search/buildonly/lucene-search-context.xml b/config/alfresco/subsystems/Search/buildonly/lucene-search-context.xml
index aa47aae1e8..bc9fd1629d 100644
--- a/config/alfresco/subsystems/Search/buildonly/lucene-search-context.xml
+++ b/config/alfresco/subsystems/Search/buildonly/lucene-search-context.xml
@@ -355,6 +355,9 @@
+
+ ${category.queryFetchSize}
+
diff --git a/config/alfresco/subsystems/Search/solr/solr-search-context.xml b/config/alfresco/subsystems/Search/solr/solr-search-context.xml
index 62e95b020f..5287f76f3b 100644
--- a/config/alfresco/subsystems/Search/solr/solr-search-context.xml
+++ b/config/alfresco/subsystems/Search/solr/solr-search-context.xml
@@ -284,6 +284,9 @@
+
+ ${category.queryFetchSize}
+
+
+ ${category.queryFetchSize}
+
+
+ ${category.queryFetchSize}
+
getChildren(NodeRef categoryRef, Mode mode, Depth depth)
+ }
+
+ public void setQueryFetchSize(int queryFetchSize) {
+ this.queryFetchSize = queryFetchSize;
+ }
+
+ public Collection getChildren(NodeRef categoryRef, Mode mode, Depth depth)
{
- return getChildren(categoryRef, mode, depth, false, null);
+ return getChildren(categoryRef, mode, depth, false, null, queryFetchSize);
}
public Collection getChildren(NodeRef categoryRef, Mode mode, Depth depth, String filter)
{
- return getChildren(categoryRef, mode, depth, false, filter);
+ return getChildren(categoryRef, mode, depth, false, filter, queryFetchSize);
}
- private Collection getChildren(NodeRef categoryRef, Mode mode, Depth depth, boolean sortByName, String filter)
+ private Collection getChildren(NodeRef categoryRef, Mode mode, Depth depth, boolean sortByName, String filter, int fetchSize)
{
if (categoryRef == null)
{
@@ -226,8 +232,8 @@ public class LuceneCategoryServiceImpl implements CategoryService
}
searchParameters.setQuery(luceneQuery.toString());
searchParameters.setLimit(-1);
- searchParameters.setMaxItems(Integer.MAX_VALUE);
- searchParameters.setLimitBy(LimitBy.UNLIMITED);
+ searchParameters.setMaxItems(fetchSize);
+ searchParameters.setLimitBy(LimitBy.FINAL_SIZE);
searchParameters.addStore(categoryRef.getStoreRef());
resultSet = searcher.query(searchParameters);
@@ -394,7 +400,7 @@ public class LuceneCategoryServiceImpl implements CategoryService
OUTER: for(NodeRef nodeRef : nodeRefs)
{
- Collection children = getChildren(nodeRef, Mode.SUB_CATEGORIES, Depth.IMMEDIATE, sortByName, filter);
+ Collection children = getChildren(nodeRef, Mode.SUB_CATEGORIES, Depth.IMMEDIATE, sortByName, filter, skipCount + maxItems);
for(ChildAssociationRef child : children)
{
count++;
@@ -454,7 +460,7 @@ public class LuceneCategoryServiceImpl implements CategoryService
Set nodeRefs = getClassificationNodes(storeRef, aspectName);
for (NodeRef nodeRef : nodeRefs)
{
- assocs.addAll(getChildren(nodeRef, Mode.SUB_CATEGORIES, Depth.IMMEDIATE, false, filter));
+ assocs.addAll(getChildren(nodeRef, Mode.SUB_CATEGORIES, Depth.IMMEDIATE, false, filter, queryFetchSize));
}
return assocs;
}