O'Reilly logo

Building a Recommendation Engine with Scala by Saleem Ansari

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Adding recommendation pages

All the recommendations we will add are global recommendations, that is, they will be the same for any user arriving on the website. Next we will add these views: Top Rated, Most Popular, and Monthly Trends.

The Top Rated view

This view will show only the first 100 products with the highest average ratings. Since we already have the average rating available in our dataset, we can make a simple database query. This is exactly what we will do. Check out the file named webapp-recommender/app/util/ReactiveDB.scala, which contains the following code:

The Top Rated view

Corresponding to that, we have code in our Play framework's controller code ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required