Reputation: 10482
I have following situation:
User (userId,Name)
Group (groupId,groupName,createdTime)
User ------ created -------> Group1
User ------ created -------> Group2
User ------ created -------> Group3
I want to get the list of group created by user in desending order. I have this query
//g is TitanGraph
g.query().interval("createdTime",0,time).orderBy("createdTime",
Order.DESC).limit(5).vertices();
This will traverse whole graph. but i want for the specific user using userId
Means i will take userId
and show all group created by that userId
sorted by createdTime
One I was trying
g.query().has(`userId`,'xyz').interval("createdTime",0,time).orderBy("createdTime",
Order.DESC).limit(5).vertices();
Din't work.it was just returning nothing.
Upvotes: 0
Views: 788
Reputation: 9989
What about this?
g.v(userId).outE.interval("createdTime",0,time).orderBy("createdTime", Order.DESC).limit(5);
Upvotes: 1
Reputation: 46206
You are using a Graph Query when you want a Vertex Query:
https://github.com/thinkaurelius/titan/wiki/Vertex-Centric-Indices
Query the vertex first and then execute the query from there, like:
Vertex v = g.getVertex(userId)
v.query().has(`userId`,'xyz').interval("createdTime",0,time).orderBy("createdTime",
Order.DESC).limit(5).vertices()
I guess this is basically the answer from @MarcoCI written with Titan/Java instead of Gremlin.
Upvotes: 1