1

I try to build relations graph based on social media content using ArangoDB. currently i have these document type collections :

  • content
  • user

and these edge type collections

  • comment
  • post
  • post_mentions
  • user_mentions
  • repost

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!

1 Answer 1

0

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}
Sign up to request clarification or add additional context in comments.

2 Comments

Hi @mpv1989 thanks for your suggestion, i tried the query but it gives me following error : Query: syntax error, unexpected WITH keyword near 'WITH user, content FOR node, edg...' at position 2:3 (while parsing) any ideas why?
I updated the query in my answer. now it should work.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.