我正在尝试使用laravel和docker对我的页面搜索功能使用elasticsearch。在执行测试运行后,它会返回此错误:
例外:“ Elasticsearch \ Common \ Exceptions \ NoNodesAvailableException” 文件:“ / var / www / vendor / elasticsearch / elasticsearch / src / Elasticsearch / ConnectionPool / StaticNoPingConnectionPool.php”
行:53
消息:“在群集中找不到活动的节点”
我正在遵循GitHub中所述的说明。我已经在"elasticquent/elasticquent": "dev-master"
文件中添加了composer.json
,并且在我的Elasticquent\ElasticquentServiceProvider::class,
文件中也添加了'Elasticsearch' => Elasticquent\ElasticquentElasticsearchFacade::class,
和app.php
。
这是我的模型的样子:
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use Elasticquent\ElasticquentTrait;
class Item extends Model
{
use ElasticquentTrait;
/**
* The attributes that are mass assignable.
*
* @var array
*/
protected $fillable = [
'name'
];
/**
* cast dates
*
* @var array
*/
protected $dates = ['created_at', 'updated_at'];
/**
* The elasticsearch settings.
*
* @var array
*/
protected $indexSettings = [
'analysis' => [
'char_filter' => [
'replace' => [
'type' => 'mapping',
'mappings' => [
'&=> and '
],
],
],
'filter' => [
'word_delimiter' => [
'type' => 'word_delimiter',
'split_on_numerics' => false,
'split_on_case_change' => true,
'generate_word_parts' => true,
'generate_number_parts' => true,
'catenate_all' => true,
'preserve_original' => true,
'catenate_numbers' => true,
]
],
'analyzer' => [
'default' => [
'type' => 'custom',
'char_filter' => [
'html_strip',
'replace',
],
'tokenizer' => 'whitespace',
'filter' => [
'lowercase',
'word_delimiter',
],
],
],
],
];
protected $mappingProperties = array(
'id' => array(
'type' => 'integer',
'analyzer' => 'standard'
)
);
function getIndexName()
{
return 'get_product_name';
}
config / elasticquent.php
return array(
/*
|--------------------------------------------------------------------------
| Custom Elasticsearch Client Configuration
|--------------------------------------------------------------------------
|
| This array will be passed to the Elasticsearch client.
| See configuration options here:
|
| http://www.elasticsearch.org/guide/en/elasticsearch/client/php-api/current/_configuration.html
*/
'config' => [
'hosts' => ['localhost:9200'],
'retries' => 1,
],
/*
|--------------------------------------------------------------------------
| Default Index Name
|--------------------------------------------------------------------------
|
| This is the index name that Elasticquent will use for all
| Elasticquent models.
*/
'default_index' => 'get_product_name',
);
我正在使用Windows终端在docker中运行其映像。有人可以帮我解决这个问题吗?在网上发现一些想法并没有运气。