setConnectionParams example

use Elasticsearch\Client;
use Psr\Log\LoggerInterface;
use Shopware\Bundle\ESIndexingBundle\Console\EvaluationHelperInterface;

class ClientFactory
{
    public static function createClient(array $config, LoggerInterface $eslogger, EvaluationHelperInterface $evaluationHelper): Client
    {
        $clientBuilder = EsClientBuilder::create();

        $clientBuilder->setHosts($config['hosts']);
        $clientBuilder->setConnectionParams(
            [
                'client' => [
                    'curl' => [
                        CURLOPT_HTTPHEADER => [
                            'Content-type: application/json',
                        ],
                    ],
                ],
            ]
        );

        
Home | Imprint | This part of the site doesn't use cookies.