Elasticsearch Database Exception

I am trying to use elasticsearch in my project but I get the following error:

Elasticsearch Database Exception – yii\elasticsearch\Exception

Elasticsearch request failed with code 400.

Error Info: Array


    [requestMethod] => PUT

    [requestUrl] =>

    [requestBody] => []

    [responseCode] => 400

    [responseHeaders] => Array


            [content-type] => application/json; charset=UTF-8

            [content-length] => 166


    [responseBody] => {"error":"MapperParsingException[failed to parse]; nested: ElasticsearchParseException[Failed to derive xcontent from (offset=0, length=2): [91, 93]]; ","status":400}


This is my model extending yii\elasticsearch\ACtiveRecord :


namespace common\models;

use common\models\CampanieMail;

use common\models\Templates;

class Templates2 extends \yii\elasticsearch\ActiveRecord {


     * @return array the list of attributes for this record


    public function attributes() {

        // path mapping for '_id' is setup to field 'id'

        return ['id', 'name', 'slug', 'layout'];



     * @return ActiveQuery defines a relation to the Order record (can be in other database, e.g. redis or sql)


    public function getCampanieMail() {

        return $this->hasMany(CampanieMail::className(), ['template_id' => 'id']);



     * Defines a scope that modifies the `$query` to return only active(status = 1) customers



and this is the action I used to create a document

 public function actionElastic() {

        $tpl = new \common\models\Templates2();

        $tpl ->primaryKey = 1; // in this case equivalent to $customer->id = 1;

        $tpl ->attributes = ['name' => 'test','slug'=>'test'];

        $tpl ->save();


And the configuration I used is

   'elasticsearch' => [

            'class' => 'yii\elasticsearch\Connection',

            'nodes' => [

                ['http_address' => ''],



Elasticsearch server is running well on a virtual machine with this IP address .

which version of elasticsearch are you using and do you use the latestet development code of yii2-elasticsearch, or the beta release?

yii2-elasticsearch beta needs elasticsearch < 1.0

yii2-elasticsearch dev needs elasticsearch >= 1.0

if you use the latest version of both, elasticsearch and yii, please report this issue on github: https://github.com/yiisoft/yii2/issues/new

I’m using elasticsearch 1.2.0 and in my composer file I have this “yiisoft/yii2-elasticsearch”: “*”

Problem was with the attributes:

I changed

$tpl->attributes = ['name' => 'test','slug'=>'test']; 


 $customer->setAttributes(['name' => 'test','slug'=>'testl','layout'=>'1'],false);

to add "safe" attributes and now it works fine .

Help me please some tell me where do I pick up my money