basemkhirat/elasticsearch

Namespace [connection] not found

Closed this issue · 1 comments

This error is thrown when calling the es:indices:create command with the --connection option passed. Tested using the out-of-the-box default connection

php artisan es:indices:create test_this --connection=default

And by using an alternative

php artisan es:indices:create test_this --connection=alternative

With the connections configuration setup like this:

'connections' => [

        'default' => [

            'servers' => [

                [
                    'host' => env('ELASTIC_HOST', '127.0.0.1'),
                    'port' => env('ELASTIC_PORT', 9200),
                    'user' => env('ELASTIC_USER', ''),
                    'pass' => env('ELASTIC_PASS', ''),
                    'scheme' => env('ELASTIC_SCHEME', 'http'),
                ]

            ],

            'index' => env('ELASTIC_INDEX', 'my_index'),

            // Elasticsearch handlers
            // 'handler' => new MyCustomHandler(),

            'logging' => [
                'enabled'   => env('ELASTIC_LOGGING_ENABLED',false),
                'level'     => env('ELASTIC_LOGGING_LEVEL','all'),
                'location'  => env('ELASTIC_LOGGING_LOCATION',base_path('storage/logs/elasticsearch.log'))
            ],
        ],
        'alternative' => [

            'servers' => [

                [
                    'host' => env('ELASTIC_HOST', '127.0.0.1'),
                    'port' => env('ELASTIC_PORT', 9200),
                    'user' => env('ELASTIC_USER', ''),
                    'pass' => env('ELASTIC_PASS', ''),
                    'scheme' => env('ELASTIC_SCHEME', 'http'),
                ]

            ],

            'index' => env('ELASTIC_INDEX', 'my_index'),

            // Elasticsearch handlers
            // 'handler' => new MyCustomHandler(),

            'logging' => [
                'enabled'   => env('ELASTIC_LOGGING_ENABLED',false),
                'level'     => env('ELASTIC_LOGGING_LEVEL','all'),
                'location'  => env('ELASTIC_LOGGING_LOCATION',base_path('storage/logs/elasticsearch.log'))
            ],
        ]
    ],

I had the underlying Elasticsearch client bound to app('es') like a fool