laravel 6 + elasticsearch-PHP 7.6 + XAMPP:いいえ生きているノードは、クラスタ内の見つかりません

アンドレアス・ハンター:

私が使用しelasticsearch-PHPを XAMPPと私のlaravelアプリで。

バージョン:

  • PHP:7.3
  • Laravel:^ 6.2
  • Elasticsearch:^ 7.6

AppServiceProvider.php 私は私のカスタムスカウトドライバを登録コード:

public function boot()
{
    $this->app->singleton('elasticsearch', function () {
        return ClientBuilder::create()
                ->setHosts([
                    'http://localhost/scout/public'
                ])
                ->build();
    });

    resolve(EngineManager::class)->extend('elasticsearch', function () {
        return new ElasticSearchEngine(
            app('elasticsearch')
        );
    });
}

私のカスタム検索エンジンのコード:

<?php 

namespace App\Search\Engines;

use Laravel\Scout\Engines\Engine;
use Laravel\Scout\Builder;
use Elasticsearch\Client;

class ElasticSearchEngine extends Engine
{
    protected $client;

    public function __construct(Client $client)
    {
        $this->client = $client;
    }

    /**
     * Update the given model in the index.
     *
     * @param  \Illuminate\Database\Eloquent\Collection  $models
     * @return void
     */
    public function update($models)
    {
        $models->each(function($model) {
            $params = [
                'index' => $model->searchableAs(),
                'type' => $model->searchableAs(),
                'id' => $model->id,
                'body' => $model->toSearchableArray()
            ];

            $this->client->index($params);
        });
    }
}

私の場合は、runコマンドしようとすると、php artisan scout:import App\Userメッセージを表示してElasticsearchパッケージリターンエラー:

Elasticsearch \共通\例外\ NoNodesAvailableException:いいえ生きているノードクラスタで見つかりました

ここでは、画像の説明を入力します。

どのように私は私の問題を解決することができますか?たぶん、ホストまたはXAMPPの設定に問題があることをここに?

タラマンスロフ:

まず、:)慌てないでください、私はあなたがElasticsearchがインストールされていないものだと思います。それはElasticsearchをインストールして、あなたの問題を解決するために5分かかります。

インスト

  • ダウンロード Elasticsearch公式配信をして解凍します。
  • 実行bin/elasticsearchのLinuxMacOSの実行bin\elasticsearch.batのWindows
  • ラン curl -X GET http://localhost:9200

おすすめ

転載: http://43.154.161.224:23101/article/api/json?id=20112&siteId=1