Skip to content

Commit 1341343

Browse files
committed
fix(unified-search): Remove hard-coded search result limit
A change added in #45317 introduced a hard stop (25) that prevents full search results from showing up. If there are more than 25 search results for a query only 25 can be seen. So two main issues: - Only 25 results can be seen in total no matter what. - Breaks web client pagination, which typically adds 5 results per request. Signed-off-by: nfebe <fenn25.fn@gmail.com>
1 parent 33897d0 commit 1341343

File tree

4 files changed

+11
-4
lines changed

4 files changed

+11
-4
lines changed

core/AppInfo/ConfigLexicon.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
*/
2121
class ConfigLexicon implements IConfigLexicon {
2222
public const UNIFIED_SEARCH_MIN_SEARCH_LENGTH = 'unified_search_min_search_length';
23+
public const UNIFIED_SEARCH_MAX_RESULTS_PER_REQUEST = 'unified_search_max_results_per_request';
2324

2425
public function getStrictness(): ConfigLexiconStrictness {
2526
return ConfigLexiconStrictness::IGNORE;
@@ -28,6 +29,7 @@ public function getStrictness(): ConfigLexiconStrictness {
2829
public function getAppConfigs(): array {
2930
return [
3031
new ConfigLexiconEntry(self::UNIFIED_SEARCH_MIN_SEARCH_LENGTH, ValueType::INT, 1, 'Minimum search length to trigger the request', lazy: false),
32+
new ConfigLexiconEntry(self::UNIFIED_SEARCH_MAX_RESULTS_PER_REQUEST, ValueType::INT, 25, 'Maximum number of results returned per request', lazy: false),
3133
];
3234
}
3335

core/Controller/UnifiedSearchController.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
namespace OC\Core\Controller;
1010

1111
use InvalidArgumentException;
12+
use OC\Core\AppInfo\Application;
13+
use OC\Core\AppInfo\ConfigLexicon;
1214
use OC\Core\ResponseDefinitions;
1315
use OC\Search\SearchComposer;
1416
use OC\Search\SearchQuery;
@@ -19,6 +21,7 @@
1921
use OCP\AppFramework\Http\Attribute\NoCSRFRequired;
2022
use OCP\AppFramework\Http\DataResponse;
2123
use OCP\AppFramework\OCSController;
24+
use OCP\IAppConfig;
2225
use OCP\IL10N;
2326
use OCP\IRequest;
2427
use OCP\IURLGenerator;
@@ -39,6 +42,7 @@ public function __construct(
3942
private IRouter $router,
4043
private IURLGenerator $urlGenerator,
4144
private IL10N $l10n,
45+
private IAppConfig $appConfig,
4246
) {
4347
parent::__construct('core', $request);
4448
}
@@ -72,7 +76,7 @@ public function getProviders(string $from = ''): DataResponse {
7276
* @param string $providerId ID of the provider
7377
* @param string $term Term to search
7478
* @param int|null $sortOrder Order of entries
75-
* @param int|null $limit Maximum amount of entries, limited to 25
79+
* @param int|null $limit Maximum amount of entries (capped by configurable unified-search.max-results-per-request, default: 25)
7680
* @param int|string|null $cursor Offset for searching
7781
* @param string $from The current user URL
7882
*
@@ -96,7 +100,8 @@ public function search(
96100
[$route, $routeParameters] = $this->getRouteInformation($from);
97101

98102
$limit ??= SearchQuery::LIMIT_DEFAULT;
99-
$limit = max(1, min($limit, 25));
103+
$maxLimit = $this->appConfig->getValueInt(Application::APP_ID, ConfigLexicon::UNIFIED_SEARCH_MAX_RESULTS_PER_REQUEST);
104+
$limit = max(1, min($limit, $maxLimit));
100105

101106
try {
102107
$filters = $this->composer->buildFilterList($providerId, $this->request->getParams());

core/openapi-full.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7407,7 +7407,7 @@
74077407
{
74087408
"name": "limit",
74097409
"in": "query",
7410-
"description": "Maximum amount of entries, limited to 25",
7410+
"description": "Maximum amount of entries (capped by configurable unified-search.max-results-per-request, default: 25)",
74117411
"schema": {
74127412
"type": "integer",
74137413
"format": "int64",

core/openapi.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7407,7 +7407,7 @@
74077407
{
74087408
"name": "limit",
74097409
"in": "query",
7410-
"description": "Maximum amount of entries, limited to 25",
7410+
"description": "Maximum amount of entries (capped by configurable unified-search.max-results-per-request, default: 25)",
74117411
"schema": {
74127412
"type": "integer",
74137413
"format": "int64",

0 commit comments

Comments
 (0)