Reputation: 93
I try to build relations graph based on social media content using ArangoDB. currently i have these document type collections :
and these edge type collections
each edge data collections is using _from and _to from content and user collection, for example, in my post collection, _from key is from user and _to key is from content (user to content), and so on for the others edge collection
my goal is simply to get all node and edge where timestamp is provided as filter value, and build a graph from it.
i'm aware of this documentation, which stated that graph traversal to follow edges connected to a start vertex, up to a variable depth. but in my case, i would like to do it without start vertex, rather using timestamp as filter value. is this possible?
currently, this is what i got so far for query with start vertex :
with user, content FOR node, edge, path IN 0..10
ANY 'user/twitter_xxx'
post,
repost,
comment,
user_mention,
post_mention
OPTIONS {uniqueEdges: "path"}
LIMIT 0,100
RETURN path
and this is my sample document data :
{
"created_at": 1502335201000,
"emotions": [
"neutral"
],
"hashtags": [],
"id": "xxx",
"inserted_at": "Fri Aug 11 01:29:08 WIB 2017",
"language": "id",
"media": [],
"media_type": "twitter",
"mentions": [],
"origin_id": "twitter_xxx",
"sentiment": 0,
"text": "Some text from twitter post",
"type": "twitter_post",
"user_id": "twitter_xxx"
}
i'm a bit confused to change it to using timestamp. any help or pointer would be highly appreciated, thanks!
Upvotes: 1
Views: 323
Reputation: 1891
Under the assumption that I understand you correctly and that you want all users with all contents from a defined timestamp, the following query could help you.
It iterates over all users and then starts a graph traversal with each user as start vertex and filters on created_at
on the nodes. The result is an array of objects with the user and an array of all contents which fits into the filter statement.
FOR u IN user
LET content = (
FOR node, edge, path IN 1..10
ANY u._id
post, repost, comment, user_mention, post_mention
FILTER node.created_at >= @timestamp
RETURN node)
RETURN {user: u, content}
Upvotes: 0