1
votes

I have installed the elasticsearch(version 6.4) in my local system. And I have to install this package via composer. And it installed perfectly but at the end, I'm getting following error

Loading composer repositories with package information Installing dependencies (including require-dev) from lock file Nothing to install or update Generating optimized autoload files Illuminate\Foundation\ComposerScripts::postAutoloadDump @php artisan package:discover

Elasticsearch\Common\Exceptions\InvalidArgumentException : Could not parse URI at /var/www/html/renthisto/vendor/elasticsearch/elasticsearch/src/Elasticsearch/ClientBuilder.php:669
665| {
666| $parts = parse_url($host);
667|
668| if ($parts === false) {
669| throw new InvalidArgumentException("Could not parse URI");
670| }
671|
672| if (isset($parts['port']) !== true) {
673| $parts['port'] = 9200;

Exception trace:
1 Elasticsearch\ClientBuilder::extractURIParts("http://")
/var/www/html/renthisto/vendor/elasticsearch/elasticsearch/src/Elasticsearch/ClientBuilder.php:625
2 Elasticsearch\ClientBuilder::buildConnectionsFromHosts()
/var/www/html/renthisto/vendor/elasticsearch/elasticsearch/src/Elasticsearch/ClientBuilder.php:562
Please use the argument -v to see more details. Script @php artisan package:discover handling the post-autoload-dump event returned with error code 1

Here's my composer file

{
"name": "laravel/laravel",
"description": "The Laravel Framework.",
"keywords": ["framework", "laravel"],
"license": "MIT",
"type": "project",
"require": {
    "php": "^7.1.3",
    "doctrine/dbal": "^2.8",
    "elasticsearch/elasticsearch": "^6.0",
    "fideloper/proxy": "^4.0",
    "guzzlehttp/guzzle": "^6.3",
    "jenssegers/mongodb": "^3.4",
    "laravel/framework": "5.6.*",
    "laravel/passport": "^7.0",
    "laravel/tinker": "^1.0",
    "league/flysystem-aws-s3-v3": "^1.0"
},
"require-dev": {
    "filp/whoops": "^2.0",
    "fzaninotto/faker": "^1.4",
    "mockery/mockery": "^1.0",
    "nunomaduro/collision": "^2.0",
    "phpunit/phpunit": "^7.0"
},
"autoload": {
    "classmap": [
        "database/seeds",
        "database/factories"
    ],
    "psr-4": {
        "App\\": "app/"
    }
},
"autoload-dev": {
    "psr-4": {
        "Tests\\": "tests/"
    }
},
"extra": {
    "laravel": {
        "dont-discover": [
        ]
    }
},
"scripts": {
    "post-root-package-install": [
        "@php -r \"file_exists('.env') || copy('.env.example', '.env');\""
    ],
    "post-create-project-cmd": [
        "@php artisan key:generate"
    ],
    "post-autoload-dump": [
        "Illuminate\\Foundation\\ComposerScripts::postAutoloadDump",
        "@php artisan package:discover"
    ]
},
"config": {
    "preferred-install": "dist",
    "sort-packages": true,
    "optimize-autoloader": true
},
"minimum-stability": "dev",
"prefer-stable": true

}

I didn't find any solution to this. I have following version (PHP-7.2) (Laravel-5.6) (Elasticsearch-6.4) in my local system. Thanks in advance.

1

1 Answers

2
votes

In the service.php config file, replacing the hosts worked for me.

Before(where search host was "localhost:9200")

'search' => [
    'enabled' => env('SEARCH_ENABLED', false),
    'hosts' => explode(',', env('SEARCH_HOST')),
]

After replacing the hosts, It worked.

'search' => [
    'enabled' => env('SEARCH_ENABLED', false),
    'hosts' => ['127.0.0.1'],
]