Facebook Data Import

25 views
Skip to first unread message

Innovify Agile

unread,
Mar 24, 2015, 7:56:37 PM3/24/15
to ne...@googlegroups.com
Hi all,

I am working on store facebook data (User details, Likes , Posts, comments , friends , Family , Events) into neo4j database.
For that we are first getting data from facebook APIs then storing data into neo4j.

Here i have attached graph as well.

Now my problem is how can i check node is exist or not if exist then update property and not then create not with property and relationship using batch cypher.

Thanks
 
download (1).png

Sukaant Chaudhary

unread,
Mar 24, 2015, 10:47:50 PM3/24/15
to ne...@googlegroups.com
Hi,
Try the following query:

MERGE (user:User{name:"XYZ", email:"x...@abc.com"})
ON CREATE SET user.created = timestamp()
ON MATCH SET user.lastSeen = timestamp()
RETURN user;

Hope this will help !

-Sukaant Chaudhary


--
You received this message because you are subscribed to the Google Groups "Neo4j" group.
To unsubscribe from this group and stop receiving emails from it, send an email to neo4j+un...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Michael Hunger

unread,
Mar 25, 2015, 6:06:31 PM3/25/15
to ne...@googlegroups.com
You can use merge
If you have indexes or constraints they will be used for the check

Von meinem iPhone gesendet
--
You received this message because you are subscribed to the Google Groups "Neo4j" group.
To unsubscribe from this group and stop receiving emails from it, send an email to neo4j+un...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
<download (1).png>
Message has been deleted

Innovify Agile

unread,
Mar 27, 2015, 5:17:48 AM3/27/15
to ne...@googlegroups.com
Thanks for help guys,


Yes i'm using merge as well.

Recently i'm facing server hangup error.

When i'm executing cypher query for match and create relationship for fb likes (only for 5 likes) , neo4j got disconnect  and node.relationship are messing up.

Please help me here.

Here is my query :

MATCH (ee:user) WHERE ee.kybe_id = "165" MATCH (woc0:page) WHERE woc0.fb_id = "201568430041866" MATCH (cac0:category) WHERE cac0.name = "Musician/band" MATCH (woc1:page) WHERE woc1.fb_id = "176279132441949" MATCH (cac1:category) WHERE cac1.name = "Musician/band" MATCH (woc2:page) WHERE woc2.fb_id = "115147381983974" MATCH (cac2:category) WHERE cac2.name = "Musician/band" MATCH (woc3:page) WHERE woc3.fb_id = "616076845140570" MATCH (cac3:category) WHERE cac3.name = "Musician/band" MATCH (woc4:page) WHERE woc4.fb_id = "550011758373396" MATCH (cac4:category) WHERE cac4.name = "Musician/band" MATCH (woce0:page) WHERE woce0.fb_id = "201568430041866" MATCH (cace0:category) WHERE cace0.name = "Musician/band" MATCH (woce1:page) WHERE woce1.fb_id = "176279132441949" MATCH (cace1:category) WHERE cace1.name = "Musician/band" MATCH (woce2:page) WHERE woce2.fb_id = "115147381983974" MATCH (cace2:category) WHERE cace2.name = "Musician/band" MATCH (woce3:page) WHERE woce3.fb_id = "616076845140570" MATCH (cace3:category) WHERE cace3.name = "Musician/band" MATCH (woce4:page) WHERE woce4.fb_id = "550011758373396" MATCH (cace4:category) WHERE cace4.name = "Musician/band" MERGE (ee)-[:LIKED]->(woc0) MERGE (woc0)-[:BELONGSTO]->(cac0) MERGE (ee)-[:LIKED]->(woc1) MERGE (woc1)-[:BELONGSTO]->(cac1) MERGE (ee)-[:LIKED]->(woc2) MERGE (woc2)-[:BELONGSTO]->(cac2) MERGE (ee)-[:LIKED]->(woc3) MERGE (woc3)-[:BELONGSTO]->(cac3) MERGE (ee)-[:LIKED]->(woc4) MERGE (woc4)-[:BELONGSTO]->(cac4) MERGE (ee)-[:LIKED]->(woce0) MERGE (woce0)-[:BELONGSTO]->(cace0) MERGE (ee)-[:LIKED]->(woce1) MERGE (woce1)-[:BELONGSTO]->(cace1) MERGE (ee)-[:LIKED]->(woce2) MERGE (woce2)-[:BELONGSTO]->(cace2) MERGE (ee)-[:LIKED]->(woce3) MERGE (woce3)-[:BELONGSTO]->(cace3) MERGE (ee)-[:LIKED]->(woce4) MERGE (woce4)-[:BELONGSTO]->(cace4)

Michael Hunger

unread,
Mar 27, 2015, 7:20:12 AM3/27/15
to ne...@googlegroups.com
crazy, I think this query just explodes.

0. try "explain" on that query (in 2.2) -> you should see how expensive it is
1. small statements, one merge per statement -> MATCH (a:Label {prop}),(b:Label {prop}) MERGE a->b
2. parameters for remote calls
3. you do a cross product + filter
4. do you have indexes for all your lookups :user(kybe_id), :page(fb_id), :category(name)

Michael
Reply all
Reply to author
Forward
0 new messages