forked from IBM/janusgraph-utils
-
Notifications
You must be signed in to change notification settings - Fork 0
/
twitter-like-queries.txt
40 lines (27 loc) · 2.21 KB
/
twitter-like-queries.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
Note: The following queries work assuming the super user (with node_id=1 in User.csv) name is 'Indiana Jones' and date-helper.groovy is loaded in JanusGraph console or server. If the super user name is different, simply replace it in the queries.
1. Who follows ‘Indiana Jones’?
g.V().has('name', 'Indiana Jones').in('Follows').values('name')
2. Find Indiana Jones’ tweets
g.V().has('name', 'Indiana Jones').out('Tweets').values('text')
3. Find Indiana Jones’ tweets in Jan 2017
g.V().has('name', 'Indiana Jones').outE('Tweets').has('Date',between(createDate(2017,1,1),createDate(2017,2,1))).inV().values('text')
4. Who tweeted 'Romeo'?
g.V().has('text', textContains('Romeo')).in('Tweets').dedup().values('name')
5. Who tweeted 'Romeo' in Jan 2017?
g.V().has('text', textContains('Romeo')).inE('Tweets').has('Date',between(createDate(2017,1,1),createDate(2017,2,1))).outV().dedup().values('name')
6. Who likes Indiana Jones' tweets
g.V().has('name', 'Indiana Jones').out('Tweets').in('Likes').dedup().values('name')
7. Find Indiana Jones' followers who retweeted his tweets
g.V().has('name', 'Indiana Jones').in('Follows').as('a').out('Retweets').in('Tweets').has('name', 'Indiana Jones').select('a').values('name').dedup()
8. Find Indiana Jones' tweets that his followers retweeted
g.V().has('name', 'Indiana Jones').in('Follows').out('Retweets').as('a').in('Tweets').has('name', 'Indiana Jones').select('a').by('text').dedup()
9. Find Indiana Jones' followers who retweeted his tweets and the retweeted tweets
g.V().has('name', 'Indiana Jones').in('Follows').has('name',not(within('Indiana Jones'))).as('follower').out('Retweets').as('retweet').in('Tweets').has('name', 'Indiana Jones').sideEffect{println \"${it.path().get('follower').value('name')} retweeted ===> ${it.path().get('retweet').value('text')}\" }
10.Add a new user
g.addV('User').property('name','John Doe')
11. Add a message
g.addV('Tweet').property('text','Hello, Friday!')
12. John Doe tweets a message
g.V().has('text', 'Hello, Friday!').as('a').V().has('name', 'John Doe').addE('Tweets').to('a').property('Date',createDate(2017,8,18))
13. Make John Doe follow Indiana Jones
g.V().has('name', 'Indiana Jones').as('a').V().has('name', 'John Doe').addE('Follows').to('a')