laravel和algolia package是否有办法更新索引而不是所有字段,只有我需要的字段?
答案 0 :(得分:4)
您可以在模型中使用getAlgoliaRecord()
method,并使用要索引的属性从中返回数组。
示例:
use Illuminate\Database\Eloquent\Model;
class Contact extends Model
{
use AlgoliaEloquentTrait;
public function getAlgoliaRecord()
{
return [
'indexedAttribute' => $this->indexedAttribute,
'otherIindexedAttribute' => $this->otherIindexedAttribute,
'nextIndexedAttribute' => $this->nextIndexedAttribute,
];
}
}