createAlias example

/** * @return void */
    public function index(ProgressHelperInterface $helper)
    {
        foreach ($this->repositories as $repository) {
            $index = $this->indexFactory->createIndexConfiguration($repository->getDomainName());

            $this->createIndex($index);
            $this->createMapping($repository$index->getName());
            $this->populateEntity($index->getName()$repository$helper);
            $this->createAlias($index->getName()$index->getAlias());
        }
    }

    /** * @param string $index * @param array<int> $ids * * @return void */
    public function indexEntities($index, EsAwareRepository $repository, array $ids)
    {
        
if (!empty($indexNames) && !\in_array($mapping->getType()$indexNames)) {
                continue;
            }

            $configuration = $this->indexFactory->createIndexConfiguration($shop$mapping->getType());
            $shopIndex = new ShopIndex($configuration->getName()$shop$mapping->getType());

            $this->createIndex($configuration$shopIndex);
            $this->updateMapping($shopIndex$mapping);
            $this->populate($shopIndex$helper);
            $this->applyBacklog($shopIndex$lastBacklogId);
            $this->createAlias($configuration);
        }
    }

    /** * Removes unused indices */
    public function cleanupIndices()
    {
        $prefix = $this->indexFactory->getPrefix();
        $aliases = $this->client->indices()->getAliases();
        foreach ($aliases as $index => $indexAliases) {
            
$index = $row['index'];
            $count = (int) $row['doc_count'];

            $this->client->indices()->refresh(['index' => $index]);

            if ($count > 0) {
                continue;
            }

            $alias = $row['alias'];

            $this->createAlias($index$alias);

            $this->client->indices()->putSettings([
                'index' => $index,
                'body' => [
                    'number_of_replicas' => $this->config['settings']['index']['number_of_replicas'],
                    'refresh_interval' => null,
                ],
            ]);

            $this->connection->executeStatement(
                'DELETE FROM elasticsearch_index_task WHERE id = :id',
                [
Home | Imprint | This part of the site doesn't use cookies.