May 25, 2020
0
Level 5
Mapping with elasticquent got Root mapping definition has unsupported parameters error
Hello, In Laravel 7.12.0 app I added "elasticquent/elasticquent": "dev-master" plugin and I try to implement sample data example from https://www.elastic.co/blog/a-practical-introduction-to-elasticsearch
with shakespeare.json file
But making mapping I got error :
Elasticsearch\Common\Exceptions\BadRequest400Exception
{"error":{"root_cause":[{"type":"mapper_parsing_exception","reason":"Root mapping definition has unsupported parameters: [shakespeares : {_source={enabled=true}, properties={play_name={analyzer=standard, type=string}, speech_number={analyzer=standard, type=number}, line_number={analyzer=standard, type=string}, text_entry={analyzer=standard, type=text}, speaker={analyzer=standard, type=string}, line_id={analyzer=standard, type=integer}}}]"}],"type":"mapper_parsing_exception","reason":"Failed to parse mapping [_doc]: Root mapping definition has unsupported parameters: [shakespeares : {_source={enabled=true}, properties={play_name={analyzer=standard, type=string}, speech_number={analyzer=standard, type=number}, line_number={analyzer=standard, type=string}, text_entry={analyzer=standard, type=text}, speaker={analyzer=standard, type=string}, line_id={analyzer=standard, type=integer}}}]","caused_by":{"type":"mapper_parsing_exception","reason":"Root mapping definition has unsupported parameters: [shakespeares : {_source={enabled=true}, properties={play_name={analyzer=standard, type=string}, speech_number={analyzer=standard, type=number}, line_number={analyzer=standard, type=string}, text_entry={analyzer=standard, type=text}, speaker={analyzer=standard, type=string}, line_id={analyzer=standard, type=integer}}}]"}},"status":400}
I created model /app/Shakespeare.php :
<?php
namespace App;
use DB;
use Illuminate\Database\Eloquent\Model;
use App\library\MyFuncsClass;
use Illuminate\Support\Facades\File;
use Illuminate\Support\Facades\Storage;
use Illuminate\Validation\Rule;
use Elasticquent\ElasticquentTrait;
class Shakespeare extends Model
{
use ElasticquentTrait;
protected $table = 'shakespeares';
protected $primaryKey = 'id';
public $timestamps = false;
protected $mappingProperties = array(
/* 'title' => array(
'type' => 'string',
'analyzer' => 'standard'
)*/
'line_id' => [
'type' => 'integer',
'analyzer' => 'standard'
],
'play_name' => [
'type' => 'string',
'analyzer' => 'standard' // not_analyzed
],
'speech_number' => [
'type' => 'number',
'analyzer' => 'standard'
],
'line_number' => [
'type' => 'string', // line_number??
'analyzer' => 'standard'
],
'speaker' => [
'type' => 'string',
'analyzer' => 'standard' // not_analyzed
],
'text_entry' => [
'type' => 'text',
'analyzer' => 'standard'
],
);
protected $fillable = [
'id', 'line_id', 'play_name', 'speech_number', 'line_number', 'speaker', 'text_entry', 'created_at', 'updated_at'
];
function getIndexName()
{
return 'shakespeares_root';
}
public static function setESMapping()
{
// if ( Shakespeare::mappingExists() ) {
// Shakespeare::deleteMapping();
// }
// Error pointing to line below !
$ret= Shakespeare::createIndex(/*$shards = null, $replicas = null*/);
\Log::info( '-1 setESMapping $ret ::' . print_r( $ret, true ) );
$ret= Shakespeare::putMapping( true/*$ignoreConflicts = true*/);
\Log::info( '-2 setESMapping $ret ::' . print_r( $ret, true ) );
$ret= Shakespeare::addAllToIndex();
\Log::info( '-3 setESMapping $ret ::' . print_r( $ret, true ) );
my config/elasticquent.php :
<?php
return array(
'config' => [
'hosts' => ['localhost:9200'],
'retries' => 1,
],
'default_index' => 'my_custom_index_name',
);
elasticsearch is running at the moment and I have in console :
curl localhost:9200
{
"name" : "athoe",
"cluster_name" : "elasticsearch",
"cluster_uuid" : "e53SDZ6PTMyXhbeJ0Zx7TQ",
"version" : {
"number" : "7.7.0",
"build_flavor" : "default",
"build_type" : "deb",
"build_hash" : "81a1e9eda8e6183f5237786246f6dced26a10eaf",
"build_date" : "2020-05-12T02:01:37.602180Z",
"build_snapshot" : false,
"lucene_version" : "8.5.1",
"minimum_wire_compatibility_version" : "6.8.0",
"minimum_index_compatibility_version" : "6.0.0-beta1"
},
"tagline" : "You Know, for Search"
}
I tried to hide columns in $mappingProperties , leaving only sample
'title' => array(
'type' => 'string',
'analyzer' => 'standard'
)
But I have the same error. How to fix it ?
elasticsearch : Version: 7.7.0
Thanks!
Please or to participate in this conversation.