Jakob Harder Holmelund
Jakob Harder Holmelund

Reputation: 102

Searching the facebook graph api with google app engine

This is my first question here.. :) Well.. I'm wondering if anyone has achieved this in an effecient way.

I want to search through friends friends and possibly their friends to see if some of them are present in my datastore. I've thought up several ways to do this, but they all have weaknesses.. :/

My first plan was to save the entity as

class Ent(db.Model):
  facebook_id = db.StringProperty()
  friends = db.StringListProperty()
  other_ents_count = db.IntegerProperty()

class OtherEnt(db.Model)
  ent = db.ReferenceProperty(Ent)
  #some properties I would possibly like to filter over

and then then just create entities for each facebook-id logging into my app

To search this you would then query the Ent entity with facebook_id as key

Ent.get_by_key(facebook_id).filter(other_ents_count>0)

Problem now is.. This graph is exploding from here, because I need to make a query first for the logged in users friends say 200-500, and then a query for their friends 200-500*200-500..

I looked into using mapreduce to make it concurrent, but i havn't decided on this yet.. Is there anyone who has experience with this who's got the best solution for this?

It should be mentioned that I have access to friend-list of any facebook-id I encounter, so a solution using the datastore in some smart graph-like way would probably be the way to go.

Upvotes: 2

Views: 739

Answers (1)

Amir
Amir

Reputation: 4151

I agree with Nick's comment, but I do feel this is particularly hard on GAE. Graph databases are more suited for this problem.

The being said, you might be able to get something working on GAE using bloom filters.

The bloom filter would narrow down the number of records you have to search. This, along with something like what is asked in Intersection on Google App Engine could lead you towards a solution. (Make sure to read my comment)

Upvotes: 1

Related Questions