Skip to content

Commit 7a18d0e

Browse files
committed
5739: Only expand search results if fuzzy search is active
Page size 99999 was introduced to fix a pagination bug with merged fuzzy and non-fuzzy results
1 parent 2790521 commit 7a18d0e

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

src/Solr/Request/SearchRequest.php

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525

2626
class SearchRequest implements Request, HasFilter
2727
{
28+
const PAGESIZE_ALL = 99999;
2829
/**
2930
* @var $resource ResourceFacade
3031
*/
@@ -103,20 +104,18 @@ public function doRequest($activeFilterAttributeCodes = array())
103104
$pageSize = $this->getParamsBuilder()->getPageSize() * $this->getParamsBuilder()->getCurrentPage();
104105
$isFuzzyActive = $this->fuzzyConfig->isActive();
105106
$minimumResults = $this->fuzzyConfig->getMinimumResults();
106-
if ($this->getCurrentSort() != 'position') {
107+
if ($this->getCurrentSort() !== 'position') {
107108
$result = $this->getResultFromRequest($pageSize, $isFuzzyActive, $activeFilterAttributeCodes);
108109
return $this->sliceResult($result);
109110
} else {
110-
$result = $this->getResultFromRequest(99999, false, $activeFilterAttributeCodes);
111-
112-
$numberResults = sizeof($result->response->docs);
111+
$result = $this->getResultFromRequest($isFuzzyActive ? self::PAGESIZE_ALL : $pageSize, false, $activeFilterAttributeCodes);
112+
$numberResults = $result->documents()->count() ;
113113
if ($isFuzzyActive && (($minimumResults == 0) || ($numberResults < $minimumResults))) {
114114

115-
$fuzzyResult = $this->getResultFromRequest(99999, true, $activeFilterAttributeCodes);
115+
$fuzzyResult = $this->getResultFromRequest(self::PAGESIZE_ALL, true, $activeFilterAttributeCodes);
116116
$result = $result->merge($fuzzyResult, $pageSize);
117117
}
118-
119-
if (sizeof($result->response->docs) == 0) {
118+
if ($result->documents()->count() === 0) {
120119
$this->foundNoResults = true;
121120
$check = explode(' ', $this->queryBuilder->getSearchString()->getRawString());
122121
if (count($check) > 1) {

0 commit comments

Comments
 (0)