ErickTamayo / laravel-scout-elastic

Elastic Driver for Laravel Scout
MIT License
916 stars 242 forks source link

Sample Elasticsearch Configuration differs from code #28

Closed navneetrai closed 7 years ago

navneetrai commented 8 years ago

I think the sample configuration shown in readme should be changed to

// config/scout.php
// Set your driver to elasticsearch
    'driver' => env('SCOUT_DRIVER', 'elasticsearch'),

...
    'elasticsearch' => [
        'index' => env('ELASTICSEARCH_INDEX', 'laravel'),
        'config'=>[
            'hosts' => [
                env('ELASTICSEARCH_HOST', 'http://localhost'),
            ]
        ],
    ],
...

The provider is picking us hosts from

config('scout.elasticsearch.config.hosts')
reyazmoosa commented 8 years ago

@navneetrai

I am trying to setup elasticsearch with elastic.co cloud account. configuration is given below.

'elasticsearch' => [ 'index' => env('ELASTICSEARCH_INDEX', 'laravel'),

'config' => [
    'hosts' => [
        'http://xxxxxxxxxxxxxxxxxxxx.ap-southeast-1.aws.found.io:9200/'
    ],
],

],

I could not find a way to pass authentication details. It is throwing an error given below

[Elasticsearch\Common\Exceptions\BadRequest400Exception] security_exception: action [indices:data/write/bulk] requires authentication

[Elasticsearch\Common\Exceptions\BadRequest400Exception] {"error":{"root_cause":[{"type":"security_exception","reason":"action [indices:data/write/bulk] requires authentication","header":{"WWW-Authenticate":"Basic realm=\"shield\" charset=\"UTF- 8\""}}],"type":"security_exception","reason":"action [indices:data/write/bulk] requires authentication","header":{"WWW-Authenticate":"Basic realm=\"shield\" charset=\"UTF-8\""}},"status":4 01}

Any help is highly appreciated .

@ErickTamayo

navneetrai commented 8 years ago

@reyazmoosa

  1. Can you please try using port 80 instead of 9200. I have read somewhere that aws elasticsearch use port 80.
  2. If this fails, can you please try to upload data to your aws elasticsearch host using curl. You can find out the details at http://docs.aws.amazon.com/elasticsearch-service/latest/developerguide/es-gsg-upload-data.html

My config was similar to your's except I was not using http:// part in host. This worked perfectly for me (without any authentication info).

reyazmoosa commented 8 years ago

Thanks @navneetrai for the quick response.

Actually I had to pass username and password to authenticate. Following is the sample configuration worked for me

'elasticsearch' => [ 'index' => env('ELASTICSEARCH_INDEX', 'laravel'), 'config' => [ 'hosts' => [ 'https://myusername:mypassword@xxxxxxxxxxxxxx.ap-southeast-1.aws.found.io:9243/' ], ], ],