I have a very basic news feed modelled in IBM Graph (TitanDB backed by Cassandra) as shown below:
I am trying to write a query that does the following:
- Start at vertex
USER: John.Smith
- Get the 15 most recent posts from the users
FRIENDS
combined with his own. - Check to see if
USER: John.Smith
likes any of those posts and return as a simpleis_liked
boolean property for each post.
There are a couple of pre-requisites for this query:
- In each returned post, the properties of the posting
USER
should also be returned. For the sake of this question, only theavatar
property is required. - I need to be able to paginate these results. i.e. Once I have retrieved the top 15 posts, I then need to be able to return the next 15, then the next etc.
I have no problem getting the users friends, and their LATEST_POSTS
:
g.V().hasLabel("USER").has("userid", "John.Smith").both("FRIEND").out("LATEST_POST");
I have read the Tinkerpop documentation but am finding myself still lost as to how to begin building upon this query in order to meet my requirements.
Also, any commentary on this approach in terms of performance, data modelling, schema or indexing advice would be extremely helpful. i.e Should I expect this approach to be able to retrieve feeds in real-time at scale?
Thanks in advance.