gpt4 book ai didi

php - Laravel 模型可以针对每个具有不同属性的多个 Algolia 索引吗?

转载 作者:搜寻专家 更新时间:2023-10-31 21:52:53 24 4
gpt4 key购买 nike

我一直在试验 algoliasearch-laravel包。

我看到模型可以通过在模型中使用 public $indices 数组来定位多个索引。

我还看到可以使用 getAlgoliaRecord() 方法指定将哪些属性发送到索引。

我的问题是,单个模型是否可以将不同的属性发送到不同的索引?

最佳答案

我有同样的要求。已打开拉取请求以添加此功能 here .

同时,您可以简单地更新您的 composer.json 以手动包含存储库。

"repositories": [
{
"type": "vcs",
"url": "https://github.com/lxrco/algoliasearch-laravel-4.git"
}
],

要使用它,您可以访问模型 getAlgoliaRecord 方法中的 indexName,如下所示:

public function getAlgoliaRecord($indexName)
{
$extraData = [];

if ($indexName === 'private_contacts') {
$extraData = [
'personal_number' => $this->personal_number,
'home_address' => $this->home_address
];
}

return array_merge($this->toArray(), $extraData);
}

关于php - Laravel 模型可以针对每个具有不同属性的多个 Algolia 索引吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37994813/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com