Я использую Elasticsearch через Docker, используя следующие 2 команды в Ubuntu 16.04 с версией PHP 7.3.6
docker pull docker.elastic.co/elasticsearch/elasticsearch:7.1.1
docker run -d --rm --name search-aol -p 9200:9200 -p 9300:9300 -e discovery.type=single-node -e http.cors.enabled=true -e http.cors.allow-origin=http://localhost:1358,http://127.0.0.1:1358 -e http.cors.allow-headers=X-Requested-With,X-Auth-Token,Content-Type,Content-Length,Authorization -e http.cors.allow-credentials=true -d docker.elastic.co/elasticsearch/elasticsearch:7.1.1
Я следовал этому учебник .
Модель
class Article extends Model
{
use ElasticquentTrait;
protected $fillable = ['title', 'body', 'tags'];
protected $mappingProperties = array(
'title' => [
'type' => 'text',
'analyzer' => 'standard',
],
'body' => [
'type' => 'text',
'analyzer' => 'standard',
],
'tags' => [
'type' => 'text',
'analyzer' => "standard",
],
);
public function getTypeName()
{
return 'article_type_name';
}
}
При попытке создать индекс я получаю исключение.
use App\Article;
Route::get('/test', function () {
Article::createIndex($shards = null, $replicas = null);
Article::putMapping($ignoreConflicts = true);
Article::addAllToIndex();
return view('welcome');
});
asticquent.php
return array(
'config' => [
'hosts' => ['localhost:9200'],
'retries' => 1,
],
'default_index' => 'laravel_test',
);
Мои пакеты
"php": "^7.1.3",
"elasticquent/elasticquent": "dev-master",
"elasticsearch/elasticsearch": "6.1.0",
Ниже приведена ошибка, возникающая при создании индекса
{
"error": {
"root_cause": [
{
"type": "mapper_parsing_exception",
"reason": "Root mapping definition has unsupported parameters: [article_type_name : {_source={enabled=true}, properties={title={analyzer=standard, type=text}, body={analyzer=standard, type=text}, tags={analyzer=standard, type=text}}}]"
}
],
"type": "mapper_parsing_exception",
"reason": "Failed to parse mapping [_doc]: Root mapping definition has unsupported parameters: [article_type_name : {_source={enabled=true}, properties={title={analyzer=standard, type=text}, body={analyzer=standard, type=text}, tags={analyzer=standard, type=text}}}]",
"caused_by": {
"type": "mapper_parsing_exception",
"reason": "Root mapping definition has unsupported parameters: [article_type_name : {_source={enabled=true}, properties={title={analyzer=standard, type=text}, body={analyzer=standard, type=text}, tags={analyzer=standard, type=text}}}]"
}
},
"status": 400
}
Пожалуйста, дайте мне знать, в чем проблема.