Recommended way to query friends or friends of friends in social graph

(Andreas Saebjoernsen) #1

I am working on a web application for getting people together by
making it easy to create and discover events, and we'd like to
recommend events using elastic search. Events that are attended by
friends and/or friends of friends should show up with a higher
relevancy. We are currently not sure how to best query for this.

This is pseudo code for our data model:


  • has many users as friends ( a single array of id's)


  • has many users as attendees (a single array of id's)

We are getting friend data from Facebook so there are going to be many
more friends and friends of friends than events.

Any tips on how to create a query that lists upcoming events,
returning events attended by friends and/or friends of friends with a
higher relevancy, is greatly appreciated.


(Karussell) #2

when I 'xy' have a friend timetabling and pannous I could use the
following to boost the results and get my friends first:

user:(timetabling^10 OR pannous^10 OR :)

This should work for a lot of friends. You could use this query type:

Another possibility would be to create two queries and boosting the
friend query + combining it with OR. To avoid a lot of boolean OR
clauses you could then construct the friend query via 'forUser:xy',
but you'll need to attach the forUser information while indexing (less
flexible when friends change often)

BTW: lucene has an upper limitation for 1024 bool clauses but you can
increase it () or ES already has it by default, not sure.



(system) #3