Answer the question
In order to leave comments, you need to log in
Why is data not being added to Elasticsearch?
Hello!
There is an ActiveRecord Elasticsearch model:
<?php
namespace app\models;
use \yii\elasticsearch\ActiveRecord;
class Test extends ActiveRecord {
function attributes()
{
return ['message', 'timestamp'];
}
function rules()
{
return [
[$this->attributes(), 'safe']
];
}
}
$q = new \app\models\Test();
$q->attributes = [
'message' => 'Сообщение',
'timestamp' => time(),
];
// $q->primaryKey = 1;
$q->save();
Elasticsearch Database Exception – yii\elasticsearch\Exception
Elasticsearch request failed with code 400.
Error Info: Array
(
[requestMethod] => POST
[requestUrl] => http://127.0.0.1:9200/tests/test?op_type=create
[requestBody] => {"message":"Сообщение","timestamp":1477937279}
[responseCode] => 400
[responseHeaders] => Array
(
[content-type] => application/json; charset=UTF-8
[content-length] => 311
)
[responseBody] => Array
(
[error] => Array
(
[root_cause] => Array
(
[0] => Array
(
[type] => action_request_validation_exception
[reason] => Validation Failed: 1: an id must be provided if version type or value are set;
)
)
[type] => action_request_validation_exception
[reason] => Validation Failed: 1: an id must be provided if version type or value are set;
)
[status] => 400
)
)
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question