laravel algolia 仅发送特定字段
laravel algolia send only specific fields
有没有办法用 laravel 和 algolia package 更新索引而不是所有字段而只更新我需要的字段?
您可以在您的模型中使用 getAlgoliaRecord()
method,并使用其中包含您要索引的属性的 return 数组。
示例:
use Illuminate\Database\Eloquent\Model;
class Contact extends Model
{
use AlgoliaEloquentTrait;
public function getAlgoliaRecord()
{
return [
'indexedAttribute' => $this->indexedAttribute,
'otherIindexedAttribute' => $this->otherIindexedAttribute,
'nextIndexedAttribute' => $this->nextIndexedAttribute,
];
}
}
有没有办法用 laravel 和 algolia package 更新索引而不是所有字段而只更新我需要的字段?
您可以在您的模型中使用 getAlgoliaRecord()
method,并使用其中包含您要索引的属性的 return 数组。
示例:
use Illuminate\Database\Eloquent\Model;
class Contact extends Model
{
use AlgoliaEloquentTrait;
public function getAlgoliaRecord()
{
return [
'indexedAttribute' => $this->indexedAttribute,
'otherIindexedAttribute' => $this->otherIindexedAttribute,
'nextIndexedAttribute' => $this->nextIndexedAttribute,
];
}
}