Answer the question
In order to leave comments, you need to log in
How to update search index when data changes?
Hello! The site uses this component to organize post searches. There was a need to update some url records in the database. As a result, now these updated records are loaded with old links when searching. Is it possible to somehow partially update the search index? In the model in the method behaviors
like this:
'searchScope' => function ($model) {
/** @var \yii\db\ActiveQuery $model */
$model->select(['name', 'text', 'id', 'image', 'slug']);
},
'searchFields' => function ($model) {
/** @var self $model */
return [
['name' => 'name', 'value' => $model->name],
['name' => 'text', 'value' => strip_tags($model->text)],
['name' => 'img', 'value' => $model->image, 'type' => SearchBehavior::FIELD_UNINDEXED],
['name' => 'url', 'value' => $model->slug, 'type' => SearchBehavior::FIELD_UNINDEXED],
];
}
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