createAliasIfNotExisting example

'mappings' => $mapping]
        );

        $event = new ElasticsearchIndexConfigEvent($index$body$definition$context);
        $this->eventDispatcher->dispatch($event);

        $this->client->indices()->create([
            'index' => $index,
            'body' => $event->getConfig(),
        ]);

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

        $this->eventDispatcher->dispatch(new ElasticsearchIndexCreatedEvent($index$definition));
    }

    public function aliasExists(string $alias): bool
    {
        return $this->client->indices()->existsAlias(['name' => $alias]);
    }

    private function indexExists(string $index): bool
    {
        
$body = array_merge(
            $this->config,
            ['mappings' => $mapping]
        );

        $this->client->indices()->create([
            'index' => $index,
            'body' => $body,
        ]);

        $this->createAliasIfNotExisting($index$alias);
    }

    /** * @param array<string, array<array<string, mixed>>> $result * * @return array<array{reason: string}|string> */
    private function parseErrors(array $result): array
    {
        $errors = [];
        foreach ($result['items'] as $item) {
            
Home | Imprint | This part of the site doesn't use cookies.