How would you implement a "liked / followed" filter


I have an index of ~50000 books. My users can mark one of the books as read.

I want to add an option to the search engine to show only unread/read books to the user.

I got this working by adding a property with the ids of the users who have read the book, to each object of the index:

  has_read: {

So I can use a filter with the user_id to only get the unread book of a user.

I’m not happy with this, as if the user base grows the object will get too big, also this makes it possible to find all book that another user as read and I would like to avoid that.

How would you implement this behavior?

Hey Nicolas,

This is actually the proper way to do it. There’s a feature called Personalization available for Business and Enterprise plans which goes a bit further: Merchandising | Algolia. When enabled, you can even generate specific API keys for users which applies a pre-filter.

I understand your concerns though. It should not affect much your search performance. Can you confirm that everything still work smoothly on your side?

1 Like

Thank you for your quick answer,

It just felt a little “hacky” so I thought there would be some more “built-in” way of doing it.
This works great, with good performance, the privacy part is the part that worries me the most but I can apply some hashing on my side to hide the ids.

Personalization looks great but the price tier is less accessible :wink: