Reputation: 995
I am trying to make a social network. I am using Neo4j to show relations between entities like different users, users and locations like cities, users and groups like music, etc. I am making friends suggestion like in Facebook the result is judged on many criteria, say we want to suggest friend for user1 and trying to judge user2 for the suggestion ,the criteria are:
There are different point for all the above criteria and at last average is done and the higher the average the higher the rank of user2 in friends suggestion list.
I think I got idea of friends suggestion but I want to implement it in neo4j via normal search query in cypher and get top 10 friend suggestion.
My questions:
Can it be done or I have to use plugins like ElasticSearch?
if yes, can you point me to any example or document
Upvotes: 1
Views: 523
Reputation: 41706
Something like:
MATCH (u:User {login:{login}})-[:LIVES_IN]->(location)
MATCH (u)-[:FRIEND]->(friend)<-[:FRIEND]-(other)
WITH u,location,other,count(*) as friends
MATCH (u)-[:LIKED]->(thing)<-[:LIKED]-(other)
WITH u,location,other,friends, count(*) as things
MATCH (other)-[:LIVES_IN]->(location)
RETURN u,other,friends+things as score
ORDER BY score DESC
LIMIT 10
Upvotes: 1
Reputation: 20185
For sure, this can be done with neo4j without use of ElasticSearch, just make a good use of labels.
For "does user2 live near user1", maybe you'll need the neo4j spatial plugin.
Some examples regarding social graphs, you'll sure find some more by looking in google.
http://docs.neo4j.org/chunked/stable/data-modeling-examples.html
Chris
Upvotes: 1