Skip to content

Commit d317417

Browse files
committed
MC-16239: Search result page contain 24k results
1 parent 109142e commit d317417

File tree

3 files changed

+29
-6
lines changed
  • app/code/Magento
  • lib/internal/Magento/Framework/Search

3 files changed

+29
-6
lines changed

app/code/Magento/CatalogSearch/Model/ResourceModel/Advanced/Collection.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,10 @@ public function addFieldsToFilter($fields)
247247
*/
248248
public function setOrder($attribute, $dir = Select::SQL_DESC)
249249
{
250+
/**
251+
* This changes need in backward compatible reasons for support dynamic improved algorithm
252+
* for price aggregation process.
253+
*/
250254
$this->setSearchOrder($attribute, $dir);
251255
if ($this->defaultFilterStrategyApplyChecker->isApplicable()) {
252256
parent::setOrder($attribute, $dir);

app/code/Magento/Elasticsearch/Elasticsearch5/SearchAdapter/Query/Builder.php

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,20 +56,17 @@ class Builder
5656
* @param SearchIndexNameResolver $searchIndexNameResolver
5757
* @param AggregationBuilder $aggregationBuilder
5858
* @param ScopeResolverInterface $scopeResolver
59-
* @param Sort|null $sortBuilder
6059
*/
6160
public function __construct(
6261
Config $clientConfig,
6362
SearchIndexNameResolver $searchIndexNameResolver,
6463
AggregationBuilder $aggregationBuilder,
65-
ScopeResolverInterface $scopeResolver,
66-
Sort $sortBuilder = null
64+
ScopeResolverInterface $scopeResolver
6765
) {
6866
$this->clientConfig = $clientConfig;
6967
$this->searchIndexNameResolver = $searchIndexNameResolver;
7068
$this->aggregationBuilder = $aggregationBuilder;
7169
$this->scopeResolver = $scopeResolver;
72-
$this->sortBuilder = $sortBuilder ?: ObjectManager::getInstance()->get(Sort::class);
7370
}
7471

7572
/**
@@ -91,7 +88,7 @@ public function initQuery(RequestInterface $request)
9188
'from' => $request->getFrom(),
9289
'size' => $request->getSize(),
9390
'stored_fields' => ['_id', '_score'],
94-
'sort' => $this->sortBuilder->getSort($request),
91+
'sort' => $this->getSortBuilder()->getSort($request),
9592
'query' => [],
9693
],
9794
];
@@ -112,4 +109,17 @@ public function initAggregations(
112109
) {
113110
return $this->aggregationBuilder->build($request, $searchQuery);
114111
}
112+
113+
/**
114+
* Get sort builder instance.
115+
*
116+
* @return Sort
117+
*/
118+
private function getSortBuilder()
119+
{
120+
if (null === $this->sortBuilder){
121+
$this->sortBuilder = ObjectManager::getInstance()->get(Sort::class);
122+
}
123+
return $this->sortBuilder;
124+
}
115125
}

lib/internal/Magento/Framework/Search/Search.php

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,16 @@ public function search(SearchCriteriaInterface $searchCriteria)
7171

7272
$this->requestBuilder->setFrom($searchCriteria->getCurrentPage() * $searchCriteria->getPageSize());
7373
$this->requestBuilder->setSize($searchCriteria->getPageSize());
74-
$this->requestBuilder->setSort($searchCriteria->getSortOrders());
74+
75+
/**
76+
* This added in Backward compatibility purposes.
77+
* Temporary solution for an existing API of a fulltext search request builder.
78+
* It must be moved to different API.
79+
* Scope to split Search request builder API in MC-16461.
80+
*/
81+
if (method_exists($this->requestBuilder, 'setSort')) {
82+
$this->requestBuilder->setSort($searchCriteria->getSortOrders());
83+
}
7584
$request = $this->requestBuilder->create();
7685
$searchResponse = $this->searchEngine->search($request);
7786

0 commit comments

Comments
 (0)