Skip to content

Commit f8c442e

Browse files
committed
Merge remote-tracking branch 'origin/MC-36807' into 2.4-develop-pr39
2 parents 46cc318 + 87bbae1 commit f8c442e

File tree

2 files changed

+37
-2
lines changed

2 files changed

+37
-2
lines changed

app/code/Magento/Elasticsearch/Model/Adapter/Elasticsearch.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -497,6 +497,12 @@ protected function prepareIndex($storeId, $indexName, $mappedIndexerId)
497497
*/
498498
private function getMappingTotalFieldsLimit(array $allAttributeTypes): int
499499
{
500-
return count($allAttributeTypes) + self::MAPPING_TOTAL_FIELDS_BUFFER_LIMIT;
500+
$count = count($allAttributeTypes);
501+
foreach ($allAttributeTypes as $attributeType) {
502+
if (isset($attributeType['fields'])) {
503+
$count += count($attributeType['fields']);
504+
}
505+
}
506+
return $count + self::MAPPING_TOTAL_FIELDS_BUFFER_LIMIT;
501507
}
502508
}

app/code/Magento/Elasticsearch/Test/Unit/Model/Adapter/ElasticsearchTest.php

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,14 @@ protected function setUp(): void
174174
->method('getAllAttributesTypes')
175175
->willReturn(
176176
[
177-
'name' => 'string',
177+
'name' => [
178+
'type' => 'string',
179+
'fields' => [
180+
'keyword' => [
181+
'type' => "keyword",
182+
],
183+
],
184+
],
178185
]
179186
);
180187
$this->clientConfig->expects($this->any())
@@ -564,6 +571,28 @@ public function testUpdateIndexMappingWithAliasDefinition(): void
564571
$this->model->updateIndexMapping($storeId, $mappedIndexerId, $attributeCode);
565572
}
566573

574+
/**
575+
* Test for get mapping total fields limit
576+
*
577+
* @return void
578+
*/
579+
public function testGetMappingTotalFieldsLimit(): void
580+
{
581+
$settings = [
582+
'index' => [
583+
'mapping' => [
584+
'total_fields' => [
585+
'limit' => 1002
586+
]
587+
]
588+
]
589+
];
590+
$this->client->expects($this->at(1))
591+
->method('createIndex')
592+
->with(null, ['settings' => $settings]);
593+
$this->model->cleanIndex(1, 'product');
594+
}
595+
567596
/**
568597
* Get elasticsearch client options
569598
*

0 commit comments

Comments
 (0)