basemkhirat / elasticsearch

The missing elasticsearch ORM for Laravel, Lumen and Native php applications
MIT License
401 stars 130 forks source link

Namespace [connection] not found #82

Closed imikemiller closed 6 years ago

imikemiller commented 6 years ago

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'))
            ],
        ]
    ],
imikemiller commented 6 years ago

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