Skip to content

Commit 1e66844

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 1e66844

4 files changed

Lines changed: 64 additions & 4 deletions

File tree

core/AppInfo/ConfigLexicon.php

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,69 @@
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;
2627
}
2728

2829
public function getAppConfigs(): array {
2930
return [
31+
<<<<<<< HEAD
3032
new ConfigLexiconEntry(self::UNIFIED_SEARCH_MIN_SEARCH_LENGTH, ValueType::INT, 1, 'Minimum search length to trigger the request', lazy: false),
33+
=======
34+
new Entry(
35+
key: self::SHAREAPI_ALLOW_FEDERATION_ON_PUBLIC_SHARES,
36+
type: ValueType::BOOL,
37+
defaultRaw: true,
38+
definition: 'adds share permission to public shares to allow adding them to your Nextcloud (federation)',
39+
lazy: true,
40+
),
41+
new Entry(
42+
key: self::SHARE_CUSTOM_TOKEN,
43+
type: ValueType::BOOL,
44+
defaultRaw: fn (Preset $p): bool => match ($p) {
45+
Preset::FAMILY, Preset::PRIVATE => true,
46+
default => false,
47+
},
48+
definition: 'Allow users to customize share URL',
49+
lazy: true,
50+
note: 'Shares with guessable tokens may be accessed easily. Shares with custom tokens will continue to be accessible after this setting has been disabled.',
51+
),
52+
new Entry(self::SHARE_LINK_PASSWORD_DEFAULT, ValueType::BOOL, false, 'Ask for a password when sharing document by default'),
53+
new Entry(
54+
key: self::SHARE_LINK_PASSWORD_ENFORCED,
55+
type: ValueType::BOOL,
56+
defaultRaw: fn (Preset $p): bool => match ($p) {
57+
Preset::SCHOOL, Preset::UNIVERSITY, Preset::SHARED, Preset::SMALL, Preset::MEDIUM, Preset::LARGE => true,
58+
default => false,
59+
},
60+
definition: 'Enforce password protection for shared documents'
61+
),
62+
new Entry(
63+
key: self::SHARE_LINK_EXPIRE_DATE_DEFAULT,
64+
type: ValueType::BOOL,
65+
defaultRaw: fn (Preset $p): bool => match ($p) {
66+
Preset::SHARED, Preset::SMALL, Preset::MEDIUM, Preset::LARGE => true,
67+
default => false,
68+
},
69+
definition: 'Default expiration date for shares via link or mail'
70+
),
71+
new Entry(
72+
key: self::SHARE_LINK_EXPIRE_DATE_ENFORCED,
73+
type: ValueType::BOOL,
74+
defaultRaw: fn (Preset $p): bool => match ($p) {
75+
Preset::SHARED, Preset::SMALL, Preset::MEDIUM, Preset::LARGE => true,
76+
default => false,
77+
},
78+
definition: 'Enforce expiration date for shares via link or mail'
79+
),
80+
new Entry(self::LASTCRON_TIMESTAMP, ValueType::INT, 0, 'timestamp of last cron execution'),
81+
new Entry(self::OCM_DISCOVERY_ENABLED, ValueType::BOOL, true, 'enable/disable OCM', lazy: true),
82+
new Entry(self::OCM_INVITE_ACCEPT_DIALOG, ValueType::STRING, '', 'route to local invite accept dialog', lazy: true, note: 'set as empty string to disable feature'),
83+
new Entry(self::UNIFIED_SEARCH_MIN_SEARCH_LENGTH, ValueType::INT, 1, 'Minimum search length to trigger the request', lazy: false, rename: 'unified-search.min-search-length'),
84+
new Entry(self::UNIFIED_SEARCH_MAX_RESULTS_PER_REQUEST, ValueType::INT, 25, 'Maximum results returned per search request', lazy: false, rename: 'unified-search.max-results-per-request'),
85+
>>>>>>> 2053112887 (fix(unified-search): Remove hard-coded search result limit)
3186
];
3287
}
3388

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)