I'm trying to use elasticsearch for my search function of my page using laravel and docker. As I've do the test run, it returns this error:
exception: "Elasticsearch\Common\Exceptions\NoNodesAvailableException" file: "/var/www/vendor/elasticsearch/elasticsearch/src/Elasticsearch/ConnectionPool/StaticNoPingConnectionPool.php"
line: 53
message: "No alive nodes found in your cluster"
I'm following the instructions stated in GitHub. I have already added "elasticquent/elasticquent": "dev-master"
in my composer.json
file and added Elasticquent\ElasticquentServiceProvider::class,
and 'Elasticsearch' => Elasticquent\ElasticquentElasticsearchFacade::class,
as well in my app.php
file.
This is how my model looks like:
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',
);
I'm using my Windows terminal in running their images in docker. Can someone help me figure this out? Found no luck around the net in getting some ideas.
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire