vendredi 31 mars 2017

How to save AR object without indexing ElasticSearch in Yii2?

i am use ElasticSearch ext in my yii2 app. After $model->save() elastic save this model data to index. But sometimes my elastic server not working, and AR object saving with fatal Exception (Elasticsearch Database Exception) 'yii\elasticsearch\Exception' with message 'Elasticsearch request failed: 7 - Failed to connect to elasticsearch...'. How i can save my AR model without indexing. Something like this:

try {
  $model->save();
} catch(yii\elasticsearch\Exception $e) {
  // save $model without indexing by elastic
}




Aucun commentaire:

Enregistrer un commentaire