Init type, mapping, and fields from a index configuration array.

@param string $indexName       Processed index name.
@param array  $indexConfigData Processed index configuration.

@return array
184843
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.
        ];
    }
1118170
public function getType($indexName, $type)
	{
		$index = $this->getRegistered($indexName);

		$params = [
			'index' => $index->getInternalName(),
			'type'  => $type
		];

		return $this->elasticSearcher->getClient()->indices()->getMapping($params);
	}
1279809
protected function collectIndexedColumns($indexName, $columns, &$collectedIndexes)
	{
		/**
		 * "If the table has a multiple-column index, any leftmost prefix of the
		 * index can be used by the optimizer to find rows. For example, if you
		 * have a three-column index on (col1, col2, col3), you have indexed search
		 * capabilities on (col1), (col1, col2), and (col1, col2, col3)."
		 * @link http://dev.mysql.com/doc/refman/5.5/en/mysql-indexes.html
		*/
		$indexedColumns = array();
		foreach ($columns as $column) {
			$indexedColumns[] = $column;
			$indexedColumnsHash = $this->getColumnList($indexedColumns);
			if (!array_key_exists($indexedColumnsHash, $collectedIndexes)) {
				$collectedIndexes[$indexedColumnsHash] = array();
			}
			$collectedIndexes[$indexedColumnsHash][] = $indexName;
		}
	}
1133438
public function index(string $indexName): IndexColumnsDefiner
    {
        return new IndexColumnsDefiner(function (array $columnNames) use ($indexName) {
            $this->indexes[] = new Index($this->orm->getNamespace() . $indexName, false, $columnNames);
        });
    }
285147
protected function generateDropIndexSql( $tableName, $indexName )
    {
        if ( $indexName == 'primary' ) // handling primary indexes
        {
            $constraintName = ezcDbSchemaOracleHelper::generateSuffixedIdentName( array( $tableName ), "pkey");
            $this->queries[] = "ALTER TABLE \"$tableName\" DROP CONSTRAINT \"{$constraintName}\"";
        }
        else
        {
            $this->queries[] = "DROP INDEX \"$indexName\"";
        }
    }
1204189
public function get($indexName)
	{
		$index = $this->getRegistered($indexName);

		$params = [
			'index' => $index->getInternalName()
		];

		return $this->elasticSearcher->getClient()->indices()->getMapping($params);
	}
224428
public function bulkIndex($indexName, $type, array $data)
	{
		$params = ['body' => []];

		foreach ($data as $item) {
			$header = [
				'_index' => $indexName,
				'_type' => $type,
			];

			if (array_key_exists('id', $item)) {
				$header['_id'] = $item['id'];
			}

			// The bulk operation expects two JSON objects for each item
			// the first one should describe the operation, index, type
			// and ID. The later one is the document body.
			$params['body'][] = ['index' => $header];
			$params['body'][] = $item;
		}

		$this->elasticSearcher->getClient()->bulk($params);
	}
307709
public function getIndexQueueIndexerConfigurationByConfigurationName($configurationName, $defaultIfEmpty = [])
    {
        $path = 'plugin.tx_solr.index.queue.' . $configurationName . '.indexer.';
        $result = $this->getObjectByPathOrDefault($path, $defaultIfEmpty);
        return $result;
    }
102879
public function findIndexInArray($indexname) {
        foreach ($this->indexes as $i => $index) {
            if ($indexname == $index->getName()) {
                return $i;
            }
        }
        return null;
    }
456859
public function getIndexByName($indexName, $tableName)
    {
        $indices = $this->getIndices($tableName);

        $result = null;

        foreach ($indices as $index) {
            if ($indexName === $index['Column_name']) {
                $result = $index;
            }
        }

        return $result;
    }
230354
private function getLuceneIndex($indexName)
    {
        if (array_key_exists($indexName, $this->indexes)) {
            return $this->indexes[$indexName];
        }

        $indexPath = $this->getIndexPath($indexName);
        if (!file_exists($indexPath)) {
            $this->getIndex($indexPath, true);
        }

        return ($this->indexes[$indexName] = $this->getIndex($indexPath, false));
    }
745789
public function getTypeMapping($indexName, $typeName)
    {
        $index = $this->getIndex($indexName);
        $type = $index->getType($typeName);

        return $type->getMapping();
    }
380668
public function getDataSources(string $indexName)
    {
        $sources = [];

        if (isset($this->datasources[$indexName]) && isset($this->datasources[$indexName])) {
            foreach ($this->datasources[$indexName] as $name => $datasource) {
                if (!$datasource instanceof \Smile\ElasticsuiteCore\Api\Index\DatasourceInterface) {
                    throw new \InvalidArgumentException(
                        'Datasource must implement ' . \Smile\ElasticsuiteCore\Api\Index\DatasourceInterface::class
                    );
                }
                $sources[$name] = $datasource;
            }
        }

        return $sources;
    }
851221
public function upsertToIndex($subject, $indexName = null)
    {
        $indexName = $this->resolveIndexName($indexName);

        if ($subject instanceof Searchable) {
            $subject = [$subject];
        }

        if (is_array($subject) || $subject instanceof Traversable) {
            $searchableItems = collect($subject)
                ->each(function ($item) {
                    if (!$item instanceof Searchable) {
                        throw new InvalidArgumentException();
                    }
                })
                ->flatMap(function ($item) use($indexName) {
                    return
                        [
                            [
                                'index' => [
                                    '_id'    => $item->getSearchableId(),
                                    '_index' => $indexName,
                                    '_type'  => $item->getSearchableType(),
                                ],
                            ],

                            $item->getSearchableBody(),
                        ];
                })
                ->toArray();

            $payload['body'] = $searchableItems;

            $this->elasticsearch->bulk($payload);

            return;
        }

        throw new InvalidArgumentException('Subject must be a searchable or array of searchables');
    }
604869
public function printIndexerConfigurations($indexerConfigurations)
    {
        $content = '';
        // show indexer names
        if ($indexerConfigurations) {
            $content .= '<ol class="orderedlist">';
            foreach ($indexerConfigurations as $indexerConfiguration) {
                $content .= '<li class="summary infobox">'
                    . '<span class="title">' . $indexerConfiguration['title'] . '</span>'

                    . ' <span class="tagsmall">'
                    . $indexerConfiguration['type']
                    . '</span>'

                    . ' <span class="tagsmall">'
                    . 'UID ' . $indexerConfiguration['uid'] . '</span>'
                    . '</span>'

                    . ' <span class="tagsmall">'
                    . 'PID ' . $indexerConfiguration['pid'] . '</span>'
                    . '</span>'

                    . '</li>';
            }
            $content .= '</ol>';
        }

        return $content;
    }
184792
public function addIndex($idxdata)
    {
        if ($idxdata instanceof Index) {
            $index = $idxdata;
            $index->setTable($this);
            $index->getName(); // we call this method so that the name is created now if it doesn't already exist.
            $this->indices[] = $index;

            return $index;
        } else {
            $index = new Index($this);
            $index->loadFromXML($idxdata);

            return $this->addIndex($index);
        }
    }
837991
public function existsType($indexName, $type)
	{
		$index = $this->getRegistered($indexName);

		$params = [
			'index' => $index->getInternalName(),
			'type'  => $type
		];

		return $this->elasticSearcher->getClient()->indices()->existsType($params);
	}