Last active
December 23, 2015 17:59
-
-
Save fforbeck/6672641 to your computer and use it in GitHub Desktop.
Neo4j and Cypher (tests)
Finding the users that liked some product a few days ago.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#New graph | |
START root=node(0) | |
CREATE | |
(User1 { name:'User1' }), | |
(User2 { name: 'User2' }), | |
(User3 { name: 'User3' }), | |
(Mac { name: 'Mac' }), | |
(Samsung { name: 'Samsung' }), | |
(Brastemp { name: 'Brastemp' }), | |
(Sony { name: 'Sony' }), | |
root-[:ROOT]->User1, User1-[:LIKE {day:1378944000000}]->Sony, User1-[:LIKE {day:1378944000000}]->Samsung, | |
root-[:ROOT]->User2, User2-[:LIKE {day:1378944000000}]->Mac, User2-[:LIKE {day:1978944000000}]->Sony, User2-[:LIKE {day:1978984000000}]->Samsung, | |
root-[:ROOT]->User3, User3-[:LIKE {day:1978984000000}]->Brastemp, User3-[:LIKE {day:1978984000000}]->Mac | |
#who are the users that liked the products after the day 1379451489693 (Tue Sep 17 2013 17:58:09 GMT-0300 (BRT)) | |
START | |
n = node(0) | |
MATCH n-[*]->u-[r:LIKE]->p | |
WHERE r.day >= 1379451489693 | |
RETURN u.name as user, type(r) as relationship, p.name as product, r.day as day | |
#TODO - who are the users that liked some product between a date range? | |
#TODO - who are the users that liked at least N products? | |
#TODO - who are the users that liked at least N products filtering by date or date range? | |
#TODO - who are the users that liked the same products in the same date or date range? | |
#TODO - what are the top five liked products? | |
#TODO - an user 'X' liked a product 'P' in a date or date range? | |
#Delete all nodes and relationships | |
START n = node(*) | |
MATCH n-[r]-() | |
DELETE n, r |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment