Algolia 不僅提供強大而快速的搜尋解決方案,還提供了一個高效的推薦系統,讓你能夠根據用戶的行為和偏好提供個性化的產品推薦。今天就來試用 Algolia 推薦系統的基本功能以及如何串接 API。
Algolia 的推薦系統利用機器學習算法,根據用戶的行為和其他相關數據提供個性化的產品推薦。通過 Algolia recommend ,你可以輕鬆地建立和管理學習模型,並即時更新推薦結果以同步最新的用戶偏好。
基本上依照官方文件的教學,可以很快就把學習模型的設定建立完成。
在 Algolia 後台中,選擇或創建一個推薦模型。設定模型參數,如要考慮的用戶行為和產品屬性。
目前主要提供三種情境:
在 Laravel 中,你可以使用 Algolia API 來取得模型的推薦結果
use Algolia\AlgoliaSearch\RecommendClient;
$config = RecommendConfig::create(config('scout.algolia.id'), config('scout.algolia.secret'));
$client = RecommendClient::createWithConfig($config);
$result = $client->getRelatedProducts([
[
'indexName' => 'episodes',
'objectID' => 'App\Models\Episode::01hbmxvpkeev349c0ay3a13y81',
],
]);
/*
Response:
{
"results": [
{
"exhaustive": {
"nbHits": true,
"typo": true
},
"exhaustiveNbHits": true,
"exhaustiveTypo": true,
"hits": [
{
"_highlightResult": {
"channel_title": {
"matchLevel": "none",
"matchedWords": [],
"value": "Y Combinator"
},
"summary": {
"matchLevel": "none",
"matchedWords": [],
"value": "<p><a href=\"https://twitter.com/sama\">Sam Altman</a> interviews <a href=\"https://twitter.com/jesslivingston\">Jessica Livingston</a> for a series called How To Build The Future, which you can watch on YC’s YouTube channel: <a href=\"https://youtube.com/ycombinator\">https://youtube.com/ycombinator</a>.</p> <p>Read the transcript here: <a href=\"https://blog.ycombinator.com/jessica-livingston-on-htfbt/\">https://blog.ycombinator.com/jessica-livingston-on-htfbt/</a></p><p><br></p>"
},
"title": {
"matchLevel": "none",
"matchedWords": [],
"value": "#7 - Jessica Livingston on How to Build the Future"
}
},
"_score": 50.38,
"_tags": [
"App\\Models\\Episode::01hbmxvpkd934mw9ctwvg94b98"
],
"channel_slug": "y-combinator",
"channel_title": "Y Combinator",
"id": "01hbmxvpkd934mw9ctwvg94b98",
"image": "https://d3t3ozftmdmh3i.cloudfront.net/staging/podcast_uploaded_episode/23401959/392e9e0b343af3e5.jpeg",
"objectID": "App\\Models\\Episode::01hbmxvpkd934mw9ctwvg94b98",
"sub_title": null,
"summary": "<p><a href=\"https://twitter.com/sama\">Sam Altman</a> interviews <a href=\"https://twitter.com/jesslivingston\">Jessica Livingston</a> for a series called How To Build The Future, which you can watch on YC’s YouTube channel: <a href=\"https://youtube.com/ycombinator\">https://youtube.com/ycombinator</a>.</p> <p>Read the transcript here: <a href=\"https://blog.ycombinator.com/jessica-livingston-on-htfbt/\">https://blog.ycombinator.com/jessica-livingston-on-htfbt/</a></p><p><br></p>",
"title": "#7 - Jessica Livingston on How to Build the Future"
}
],
"hitsPerPage": 30,
"nbHits": 30,
"nbPages": 1,
"page": 0,
"processingTimeMS": 3,
"processingTimingsMS": {
"_request": {
"roundTrip": 152
},
"afterFetch": {
"format": {
"highlighting": 2,
"total": 2
},
"total": 2
},
"total": 3
},
"renderingContent": [],
"serverTimeMS": 3
}
]
}
*/
這邊是推薦結果的 demo 清單
一般來說建立推薦系統很複雜,尤其在搞懂概念與建立可以全自動及即時更新的系統更是一門水很深的功夫,在產品得到驗證之前,可以找到穩定且滿足基本需求的供應商很重要。
Algolia 建構出了一組很輕易上手的系統,但也提供了許多的參數可以微調,建議可以先在官方的文件先看過一輪可以微調的部分,說不定可以更好思考出如何建構屬於你的產品設定。