mirror of
https://github.com/nextcloud/server.git
synced 2026-06-11 01:30:50 -04:00
fix(unified-search): Remove hard-coded search result limit
A change added in https://github.com/nextcloud/server/pull/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>
This commit is contained in:
parent
33897d0c7d
commit
5d01642813
4 changed files with 11 additions and 4 deletions
|
|
@ -20,6 +20,7 @@ use NCU\Config\ValueType;
|
|||
*/
|
||||
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;
|
||||
|
|
@ -28,6 +29,7 @@ class ConfigLexicon implements IConfigLexicon {
|
|||
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),
|
||||
];
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -9,6 +9,8 @@ declare(strict_types=1);
|
|||
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;
|
||||
|
|
@ -19,6 +21,7 @@ use OCP\AppFramework\Http\Attribute\NoAdminRequired;
|
|||
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;
|
||||
|
|
@ -39,6 +42,7 @@ class UnifiedSearchController extends OCSController {
|
|||
private IRouter $router,
|
||||
private IURLGenerator $urlGenerator,
|
||||
private IL10N $l10n,
|
||||
private IAppConfig $appConfig,
|
||||
) {
|
||||
parent::__construct('core', $request);
|
||||
}
|
||||
|
|
@ -72,7 +76,7 @@ class UnifiedSearchController extends OCSController {
|
|||
* @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
|
||||
*
|
||||
|
|
@ -96,7 +100,8 @@ class UnifiedSearchController extends OCSController {
|
|||
[$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());
|
||||
|
|
|
|||
|
|
@ -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",
|
||||
|
|
|
|||
|
|
@ -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",
|
||||
|
|
|
|||
Loading…
Reference in a new issue