Indexing Facebook Feed like structure

Hi, we are considering Algolia for our searching need. We have usecase similar to feed in FB.

A user can follow other users. When the followed user publishes a new post, it should show up following user’s feed search results with a specific sort criteria (For example, Likes+age of the post etc). Apart from that, we also need to be able to query all the posts user liked and list of all posts across all users.

How is such use case implemented with Algolia? We are using Firebase for backend. If someone can point me to some example, document that would be very helpful.

Hi @amitava82!

You will want to create a process that pushes the data you have from Firebase to Algolia. A few basic strategies are in this guide, which you’ll need to adapt to your data model.

You could try having Algolia record per post, or potentially one per post per timeline that it lives in. The second approach would make it easy to filter on the user_id of the person who’s timeline is being searched, see more information about that in detail on this post:

Sorting on likes or age can be done with the custom ranking.

Thanks @dzello. I’m thinking about 2nd approach (fan out on write). It could be pretty expensive, since pricing is on record count, no? If I have few hundred users with couple of thousands followers, we can pretty quickly hit the plan limit. Also, for these kind of writes, is it OK to write one record at a time? For example, I can add handler on ‘child added’ event in firebase and push each record to Algolia.

Yeah, it’s a good point about the fanout causing a lot more records to be written. In that sense you’ll be better off with one record per post and a visible_by attribute (array of user ids probably) that you can use both for filtering and scoped API key creation.

Yes, it’s ok to do just one record at a time, no worries there.