Classes/Driver/Version5/Mapping/NodeTypeMappingBuilder.php
public function buildMappingInformation(Index $index): MappingCollection
    {
        $this->lastMappingErrors = new Result();

        $mappings = new MappingCollection(MappingCollection::TYPE_ENTITY);

        /** @var NodeType $nodeType */
        foreach ($this->nodeTypeManager->getNodeTypes() as $nodeTypeName => $nodeType) {
            if ($nodeTypeName === 'unstructured' || $nodeType->isAbstract()) {
                continue;
            }

            $type = $index->findType($this->convertNodeTypeNameToMappingName($nodeTypeName));
            $mapping = new Mapping($type);
            $fullConfiguration = $nodeType->getFullConfiguration();
            if (isset($fullConfiguration['search']['elasticSearchMapping'])) {
                $fullMapping = $fullConfiguration['search']['elasticSearchMapping'];
                $this->migrateConfigurationForElasticVersion5($fullMapping);
                $mapping->setFullMapping($fullMapping);
            }

            // https://www.elastic.co/guide/en/elasticsearch/reference/5.4/dynamic-templates.html
            $mapping->addDynamicTemplate('dimensions', [
                'path_match' => '__dimensionCombinations.*',
                'match_mapping_type' => 'string',
                'mapping' => [
                    'type' => 'text'
                ]
            ]);
            $mapping->setPropertyByPath('__dimensionCombinationHash', [
                'type' => 'keyword'
            ]);

            foreach ($nodeType->getProperties() as $propertyName => $propertyConfiguration) {
                if (isset($propertyConfiguration['search']['elasticSearchMapping'])) {
                    if (is_array($propertyConfiguration['search']['elasticSearchMapping'])) {
                        $propertyMapping = $propertyConfiguration['search']['elasticSearchMapping'];
                        $this->migrateConfigurationForElasticVersion5($propertyMapping);
                        $mapping->setPropertyByPath($propertyName, $propertyMapping);
                    }
                } elseif (isset($propertyConfiguration['type'], $this->defaultConfigurationPerType[$propertyConfiguration['type']]['elasticSearchMapping'])) {
                    if (is_array($this->defaultConfigurationPerType[$propertyConfiguration['type']]['elasticSearchMapping'])) {
                        $mapping->setPropertyByPath($propertyName, $this->defaultConfigurationPerType[$propertyConfiguration['type']]['elasticSearchMapping']);
                    }
                } else {
                    $this->lastMappingErrors->addWarning(new Warning('Node Type "' . $nodeTypeName . '" - property "' . $propertyName . '": No ElasticSearch Mapping found.'));
                }
            }

            $mappings->add($mapping);
        }

        return $mappings;
    }
public function buildMappingInformation(Index $index): MappingCollection
    {
        $this->lastMappingErrors = new Result();

        $mappings = new MappingCollection(MappingCollection::TYPE_ENTITY);

        /** @var NodeType $nodeType */
        foreach ($this->nodeTypeManager->getNodeTypes() as $nodeTypeName => $nodeType) {
            if ($nodeTypeName === 'unstructured' || $nodeType->isAbstract()) {
                continue;
            }

            $type = $index->findType($this->convertNodeTypeNameToMappingName($nodeTypeName));
            $mapping = new Mapping($type);
            $fullConfiguration = $nodeType->getFullConfiguration();
            if (isset($fullConfiguration['search']['elasticSearchMapping'])) {
                $fullMapping = $fullConfiguration['search']['elasticSearchMapping'];
                $this->migrateConfigurationForElasticVersion5($fullMapping);
                $mapping->setFullMapping($fullMapping);
            }

            // https://www.elastic.co/guide/en/elasticsearch/reference/5.4/dynamic-templates.html
            $mapping->addDynamicTemplate('dimensions', [
                'path_match' => '__dimensionCombinations.*',
                'match_mapping_type' => 'string',
                'mapping' => [
                    'type' => 'text'
                ]
            ]);
            $mapping->setPropertyByPath('__dimensionCombinationHash', [
                'type' => 'keyword'
            ]);

            foreach ($nodeType->getProperties() as $propertyName => $propertyConfiguration) {
                if (isset($propertyConfiguration['search']['elasticSearchMapping'])) {
                    if (is_array($propertyConfiguration['search']['elasticSearchMapping'])) {
                        $propertyMapping = $propertyConfiguration['search']['elasticSearchMapping'];
                        $this->migrateConfigurationForElasticVersion5($propertyMapping);
                        $mapping->setPropertyByPath($propertyName, $propertyMapping);
                    }
                } elseif (isset($propertyConfiguration['type'], $this->defaultConfigurationPerType[$propertyConfiguration['type']]['elasticSearchMapping'])) {
                    if (is_array($this->defaultConfigurationPerType[$propertyConfiguration['type']]['elasticSearchMapping'])) {
                        $mapping->setPropertyByPath($propertyName, $this->defaultConfigurationPerType[$propertyConfiguration['type']]['elasticSearchMapping']);
                    }
                } else {
                    $this->lastMappingErrors->addWarning(new Warning('Node Type "' . $nodeTypeName . '" - property "' . $propertyName . '": No ElasticSearch Mapping found.'));
                }
            }

            $mappings->add($mapping);
        }

        return $mappings;
    }
public function buildMappingInformation ( Index $ index ) : MappingCollection { $ this -> lastMappingErrors = new Result ( ) ; $ mappings = new MappingCollection ( MappingCollection :: TYPE_ENTITY ) ; /** @var NodeType $nodeType */ foreach ( $ this -> nodeTypeManager -> getNodeTypes ( ) as $ nodeTypeName => $ nodeType ) { if ( $ nodeTypeName === 'unstructured' || $ nodeType -> isAbstract ( ) ) { continue ; } $ type = $ index -> findType ( $ this -> convertNodeTypeNameToMappingName ( $ nodeTypeName ) ) ; $ mapping = new Mapping ( $ type ) ; $ fullConfiguration = $ nodeType -> getFullConfiguration ( ) ; if ( isset ( $ fullConfiguration [ 'search' ] [ 'elasticSearchMapping' ] ) ) { $ fullMapping = $ fullConfiguration [ 'search' ] [ 'elasticSearchMapping' ] ; $ this -> migrateConfigurationForElasticVersion5 ( $ fullMapping ) ; $ mapping -> setFullMapping ( $ fullMapping ) ; } // https://www.elastic.co/guide/en/elasticsearch/reference/5.4/dynamic-templates.html $ mapping -> addDynamicTemplate ( 'dimensions' , [ 'path_match' => '__dimensionCombinations.*' , 'match_mapping_type' => 'string' , 'mapping' => [ 'type' => 'text' ] ] ) ; $ mapping -> setPropertyByPath ( '__dimensionCombinationHash' , [ 'type' => 'keyword' ] ) ; foreach ( $ nodeType -> getProperties ( ) as $ propertyName => $ propertyConfiguration ) { if ( isset ( $ propertyConfiguration [ 'search' ] [ 'elasticSearchMapping' ] ) ) { if ( is_array ( $ propertyConfiguration [ 'search' ] [ 'elasticSearchMapping' ] ) ) { $ propertyMapping = $ propertyConfiguration [ 'search' ] [ 'elasticSearchMapping' ] ; $ this -> migrateConfigurationForElasticVersion5 ( $ propertyMapping ) ; $ mapping -> setPropertyByPath ( $ propertyName , $ propertyMapping ) ; } } elseif ( isset ( $ propertyConfiguration [ 'type' ] , $ this -> defaultConfigurationPerType [ $ propertyConfiguration [ 'type' ] ] [ 'elasticSearchMapping' ] ) ) { if ( is_array ( $ this -> defaultConfigurationPerType [ $ propertyConfiguration [ 'type' ] ] [ 'elasticSearchMapping' ] ) ) { $ mapping -> setPropertyByPath ( $ propertyName , $ this -> defaultConfigurationPerType [ $ propertyConfiguration [ 'type' ] ] [ 'elasticSearchMapping' ] ) ; } } else { $ this -> lastMappingErrors -> addWarning ( new Warning ( 'Node Type "' . $ nodeTypeName . '" - property "' . $ propertyName . '": No ElasticSearch Mapping found.' ) ) ; } } $ mappings -> add ( $ mapping ) ; } return $ mappings ; }
Builds a Mapping Collection from the configured node types

@param Index $index
@return MappingCollection<\Flowpack\ElasticSearch\Domain\Model\Mapping>
Builds a Mapping Collection from the configured node types