Skip to content

Commit 797edfe

Browse files
Merge pull request #46 from daniellienert/task/mapping-speedup
TASK: Speedup mapping setup on index creation
2 parents 28ea88d + 56a7111 commit 797edfe

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

Classes/Command/NodeIndexQueueCommandController.php

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -327,10 +327,22 @@ protected function updateMapping(string $indexPostfix): void
327327
$this->nodeIndexer->getIndex()->create();
328328
}
329329
$nodeTypeMappingCollection = $this->nodeTypeMappingBuilder->buildMappingInformation($this->nodeIndexer->getIndex());
330-
foreach ($nodeTypeMappingCollection as $mapping) {
331-
/** @var Mapping $mapping */
332-
$mapping->apply();
330+
331+
$properties = [];
332+
$dynamicTemplates = [];
333+
foreach ($nodeTypeMappingCollection as $nodeTypeMapping) {
334+
/** @var Mapping $nodeTypeMapping */
335+
$properties[] = $nodeTypeMapping->asArray()['properties'];
336+
$dynamicTemplates[] = $nodeTypeMapping->asArray()['dynamic_templates'];
333337
}
338+
339+
$combinedMappings = [
340+
'dynamic_templates' => array_merge([], ...$dynamicTemplates),
341+
'properties' => array_merge([], ...$properties),
342+
];
343+
344+
$this->nodeIndexer->getIndex()->request('PUT', '/_mapping', [], json_encode($combinedMappings));
345+
334346
$this->logger->info(sprintf('Mapping updated for index %s', $this->nodeIndexer->getIndexName()), LogEnvironment::fromMethodName(__METHOD__));
335347
});
336348
}

0 commit comments

Comments
 (0)