diff --git a/classes/submission/Collector.php b/classes/submission/Collector.php index b8ad72046c1..221179c4ea6 100644 --- a/classes/submission/Collector.php +++ b/classes/submission/Collector.php @@ -60,6 +60,7 @@ abstract class Collector implements CollectorInterface public string $orderBy = self::ORDERBY_DATE_SUBMITTED; public string $orderDirection = 'DESC'; public ?string $searchPhrase = null; + public ?int $maxSearchKeywords = null; public ?array $statuses = null; public ?array $stageIds = null; public ?array $doiStatuses = null; @@ -207,9 +208,10 @@ public function assignedTo($assignedTo): AppCollector /** * Limit results to submissions matching this search query */ - public function searchPhrase(?string $phrase): AppCollector + public function searchPhrase(?string $phrase, ?int $maxSearchKeywords = null): AppCollector { $this->searchPhrase = $phrase; + $this->maxSearchKeywords = $maxSearchKeywords; return $this; } @@ -293,7 +295,9 @@ public function getQueryBuilder(): Builder } // Prepare keywords (allows short and numeric words) - $keywords = collect(Application::getSubmissionSearchIndex()->filterKeywords($this->searchPhrase, false, true, true))->unique(); + $keywords = collect(Application::getSubmissionSearchIndex()->filterKeywords($this->searchPhrase, false, true, true)) + ->unique() + ->take($this->maxSearchKeywords ?? PHP_INT_MAX); // Setup the order by switch ($this->orderBy) {