private function getDynamicFields($indexName, $configData)
    {
        $fields       = [];
        $cacheId      = implode('|', [$this->cacheId, $indexName]);
        $fieldsConfig = $this->cache->load($cacheId);

        if (false === $fieldsConfig) {
            $legacyDataSources = [$indexName => $configData['datasources']]; // @deprecated.
            $resolver          = $this->dataSourceResolverFactory->create(['legacyDataSources' => $legacyDataSources]);
            $dataSources       = $resolver->getDataSources($indexName);

            /** @var DynamicFieldProviderInterface[] $dynamicFieldProviders */
            $dynamicFieldProviders = array_filter($dataSources, [$this, 'isDynamicFieldsProvider']);

            foreach ($dynamicFieldProviders as $dynamicFieldProvider) {
                $fields   += $dynamicFieldProvider->getFields();
            }

            $fieldsConfig = [];
            foreach ($fields as $fieldName => $field) {
                $fieldsConfig[$fieldName] = [
                    'type'        => $field->getType(),
                    'nestedPath'  => $field->getNestedPath(),
                    'fieldConfig' => $field->getConfig(),
                ];
            }

            $this->cache->save($this->serializer->serialize($fieldsConfig), $cacheId, $this->cacheTags + [$this->cacheId]);
        } else {
            $fieldsConfig = $this->serializer->unserialize($fieldsConfig);
        }

        foreach ($fieldsConfig as $fieldName => $fieldConfig) {
            $fields[$fieldName] = $this->mappingFieldFactory->create(['name' => $fieldName] + $fieldConfig);
        }

        return $fields;
    }