public function registerConnectionSingleton()
    {
        $this->app->singleton(Client::class, function () {

            $defaultConfig = [
                'logPath'   => storage_path().'/logs/elasticsearch-'.php_sapi_name().'.log',
            ];

            $config = array_merge($defaultConfig, config('elasticsearch'));

            $connection = array_get($config, 'connections.'.$config['defaultConnection']);

            $client = ClientBuilder::create()->setHosts($connection['hosts']);

            if ($connection['logging']) {
                $logger = ClientBuilder::defaultLogger($connection['logPath']);
                $client->setLogger($logger);
            }

            return $client->build();
        });
    }