Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions core/AppInfo/ConfigLexicon.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
*/
class ConfigLexicon implements IConfigLexicon {
public const UNIFIED_SEARCH_MIN_SEARCH_LENGTH = 'unified_search_min_search_length';
public const UNIFIED_SEARCH_MAX_RESULTS_PER_REQUEST = 'unified_search_max_results_per_request';

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

Expand Down
9 changes: 7 additions & 2 deletions core/Controller/UnifiedSearchController.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
namespace OC\Core\Controller;

use InvalidArgumentException;
use OC\Core\AppInfo\ConfigLexicon;
use OC\Core\Application;
use OC\Core\ResponseDefinitions;
use OC\Search\SearchComposer;
use OC\Search\SearchQuery;
Expand All @@ -19,6 +21,7 @@
use OCP\AppFramework\Http\Attribute\NoCSRFRequired;
use OCP\AppFramework\Http\DataResponse;
use OCP\AppFramework\OCSController;
use OCP\IAppConfig;
use OCP\IL10N;
use OCP\IRequest;
use OCP\IURLGenerator;
Expand All @@ -39,6 +42,7 @@ public function __construct(
private IRouter $router,
private IURLGenerator $urlGenerator,
private IL10N $l10n,
private IAppConfig $appConfig,
) {
parent::__construct('core', $request);
}
Expand Down Expand Up @@ -72,7 +76,7 @@ public function getProviders(string $from = ''): DataResponse {
* @param string $providerId ID of the provider
* @param string $term Term to search
* @param int|null $sortOrder Order of entries
* @param int|null $limit Maximum amount of entries, limited to 25
* @param int|null $limit Maximum amount of entries (capped by configurable unified-search.max-results-per-request, default: 25)
* @param int|string|null $cursor Offset for searching
* @param string $from The current user URL
*
Expand All @@ -96,7 +100,8 @@ public function search(
[$route, $routeParameters] = $this->getRouteInformation($from);

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

try {
$filters = $this->composer->buildFilterList($providerId, $this->request->getParams());
Expand Down
2 changes: 1 addition & 1 deletion core/openapi-full.json
Original file line number Diff line number Diff line change
Expand Up @@ -7407,7 +7407,7 @@
{
"name": "limit",
"in": "query",
"description": "Maximum amount of entries, limited to 25",
"description": "Maximum amount of entries (capped by configurable unified-search.max-results-per-request, default: 25)",
"schema": {
"type": "integer",
"format": "int64",
Expand Down
2 changes: 1 addition & 1 deletion core/openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -7407,7 +7407,7 @@
{
"name": "limit",
"in": "query",
"description": "Maximum amount of entries, limited to 25",
"description": "Maximum amount of entries (capped by configurable unified-search.max-results-per-request, default: 25)",
"schema": {
"type": "integer",
"format": "int64",
Expand Down
Loading