Skip to content

Commit 036b661

Browse files
committed
MCP-811: Performance Optimization for Catalog GraphQL
1 parent 9f43821 commit 036b661

File tree

3 files changed

+10
-1
lines changed

3 files changed

+10
-1
lines changed

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,8 @@ public function initQuery(RequestInterface $request)
9191
'body' => [
9292
'from' => min(self::ELASTIC_INT_MAX, $request->getFrom()),
9393
'size' => $request->getSize(),
94-
'stored_fields' => ['_id', '_score'],
94+
'stored_fields' => '_none_',
95+
'docvalue_fields' => ['_id', '_score'],
9596
'sort' => $this->sortBuilder->getSort($request),
9697
'query' => [],
9798
],

app/code/Magento/Elasticsearch/SearchAdapter/Aggregation/Builder/Dynamic.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,10 @@ private function getEntityStorage(array $queryResult)
5959
{
6060
$ids = [];
6161
foreach ($queryResult['hits']['hits'] as $document) {
62+
if (!array_key_exists('_id', $document) && array_key_exists('fields', $document)) {
63+
$document['_id'] = $document['fields']['_id'][0];
64+
unset($document['fields']);
65+
}
6266
$ids[] = $document['_id'];
6367
}
6468

app/code/Magento/Elasticsearch/SearchAdapter/ResponseFactory.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,10 @@ public function create($response)
6464
{
6565
$documents = [];
6666
foreach ($response['documents'] as $rawDocument) {
67+
if (!array_key_exists('_id', $rawDocument) && array_key_exists('fields', $rawDocument)) {
68+
$rawDocument['_id'] = $rawDocument['fields']['_id'][0];
69+
unset($rawDocument['fields']);
70+
}
6771
/** @var \Magento\Framework\Api\Search\Document[] $documents */
6872
$documents[] = $this->documentFactory->create(
6973
$rawDocument

0 commit comments

Comments
 (0)