algolia / algoliasearch-client-javascript

⚡️ A fully-featured and blazing-fast JavaScript API client to interact with Algolia.
https://www.algolia.com/doc/api-client/javascript/getting-started/
MIT License
1.33k stars 221 forks source link

feat(recommend): add recommended-for-you model #1490

Closed raed667 closed 9 months ago

raed667 commented 9 months ago

Description

Add getRecommendedForYou function to recommend.

Test

To test locally you can update playground/browser/index.html with the following content:

<html>
  <head>
    <script src="/playground/browser/recommend.umd.js"></script>

    <script>
      const recommend = window['@algolia/recommend'];
      const client = recommend('betaUASF0EMRRM', '2c80241f06757af6fc4ef4a2d9523b6d');

      client
        .getRecommendedForYou([
          {
            indexName: 'bestbuy',
            queryParameters: {
              userToken: 'user_token_1',
            },
          },
        ])
        .then(({ results }) => {
          console.log(results[0]);
        })
        .catch(err => {
          console.error(err);
        });
    </script>
  </head>
  <body></body>
</html>
francoischalifour commented 9 months ago

There are 3 ways of referencing "products" now:

What's the reasoning behind all these different namings? "Recommended For You" also returns products, right? And in that case, how to explain users the difference between "Recommended For You" and "Related Items" provided with a userToken?

AlexEven commented 9 months ago

Hey François, will try my best to answer your questions

How is this different from Related products with a user token? This second option is "simply" re-ranking already available recommendations to push the ones matching user affinities in priority. Just like you would apply a rule to boost a certain category, here you'd prioritize personalization.

Hope this helps. Thanks!

francoischalifour commented 9 months ago

Right, so the main difference with Recommended For You is that there's no reference product. Thanks for the clarification!

(It's unfortunate that there's this divergence between Related Products and Trending Items, while both refer to catalog records.)

shortcuts commented 9 months ago

Hey, feel free to ping me when I can merge :)

raed667 commented 9 months ago

@shortcuts this can be merged