private function initIndexConfig(string $indexName, array $indexConfigData)
    {
        $types = [];

        foreach ($indexConfigData['types'] as $typeName => $typeConfigData) {
            $fields  = $this->getMappingFields($indexName, $typeConfigData);
            $mapping = $this->mappingFactory->create(
                ['idFieldName' => $typeConfigData['idFieldName'], 'fields' => $fields]
            );

            $types[$typeName] = $this->typeFactory->create(
                ['name' => $typeName, 'mapping' => $mapping]
            );
        }

        if (count($types) > 1) {
            throw new \LogicException("Can not add several types in the same index.");
        }

        $defaultSearchType = $indexConfigData['defaultSearchType'];

        return [
            'mapping'           => $mapping,
            'types'             => $types,
            'defaultSearchType' => $defaultSearchType,
            'datasources'       => $typeConfigData['datasources'] ?? [], // @deprecated.
        ];
    }