Laravel ElasticSearch: Root mapping definition has unsupported parameters

Viewed 22

I'm trying to add in a new index using the code below, using elasticsearch (elasticquent) 7.4.0 in laravel 6.5 (server side of elasticsearch is running on a dedicated server (docker) including Kibana GUI, the connection to this is working)

    <?php

// Article.php

namespace App;
use Elasticquent\ElasticquentTrait;

use Illuminate\Database\Eloquent\Model;

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",
        ],
    );
}

But then I get the response:

{"error":{"root_cause":[{"type":"mapper_parsing_exception","reason":"Root mapping definition has unsupported parameters:  [articles : {_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:  [articles : {_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:  [articles : {_source={enabled=true}, properties={title={analyzer=standard, type=text}, body={analyzer=standard, type=text}, tags={analyzer=standard, type=text}}}]"}},"status":400}

I have been struggling with this for a while. I can't determine which parameter is unsupported. Any help is appreciated! Also, is there any way to get more detail from Kibana on the specific parameter is unsupported?

1 Answers

I think you're hitting this issue (also documented here)

You simply need to add the following function in your model and it should work:

function getTypeName()
{
    return '_doc';
}
Related