Boosting search results for Facebook friends with fb_graph, omniauth, Sunspot and Solr
Boosting in Solr allows customizing search relevance to offer users the best experience. Here’s the short and sweet on boosting at search time using the Sunspot gem so documents associated with other users who are your Facebook friends show up first.
Grab the user’s Facebook friends
This application allows users to register with their Facebook account using devise and omniauth. On login, we’ll use fb_graph to get the user’s Facebook friend ids and store them with the account. We’ll also store their API key so we can refresh this info later to ensure the list is up to date. See this page for info on getting started with omniauth and facebook.
Indexing Facebook ids for search
In our Active Record model we index the Facebook id of the user associated with the document to a “facebook_id” field: