Using ArangoDB EDGES function, can't get the right vertex with includeVertices options

24 views
Skip to first unread message

Bob Citron

unread,
Sep 22, 2015, 4:49:47 AM9/22/15
to ArangoDB
Hey guys,

I'm using ArangoDB for few days now, and I have a confusing result using a basic function. Here's a precise description of my trouble.

Using ArangoDB to describe a friend relationship, I want to know the friends of a specific user A. Because it's a test sample, I know that A is friend with B.

I have users in a document collection and an edge collection containing the information from "_from" being friend to "_to". If A is friend to B, B must be friend to A. i.e.: if there's an edge _from A _to B, an other edge _from B _to A does exist.

I use the function EDGES on my friend collection, to know which is friend to the user "u4", which _id is 2465087832. He must be friend with "u1", which _id is 2462335320.
Because I want to have more than just the document ID, I set the option "includeVertices" to true.

Here are my request.

    LET out = EDGES(friends, "db/2465087832", "outbound", null, {includeVertices: true})

And the answer:

    [
        {
          "edge": {
            "_id": "db/2468102488",
            "_from": "db/2465087832",
            "_to": "db/2462335320",
            "_rev": "2468102488",
            "_key": "2468102488"
          },
          "vertex": {
            "_id": "db/2465087832",
            "_key": "2465087832",
            "_rev": "3962323288",
            "id": "u4"
          }
        }
      ]

As a result, I have the good edge (u4 is friend to u1), but the vertex included is the one from the requested user (id: u4).
I tried using "inbound" as a direction, instead of "outbound".

    LET out = EDGES(friends, "db/2465087832", "inbound", null, {includeVertices: true})

And the result is:

     [
        {
          "edge": {
            "_id": "db/2468364632",
            "_from": "db/2462335320",
            "_to": "db/2465087832",
            "_rev": "2468364632",
            "_key": "2468364632"
          },
          "vertex": {
            "_id": "db/2465087832",
            "_key": "2465087832",
            "_rev": "3962323288",
            "id": "u4"
          }
        }
      ]

As you can see, still "u4" as vertex, even is the edge is the good one (u1 is friend to u4).

At last, I tried to use "any" as a direction.

    LET any = EDGES(friends, "db/2465087832", "any", null, {includeVertices: true})

And the surprising answer:

    [
        {
          "edge": {
            "_id": "friends/2468364632",
            "_from": "user/2462335320",
            "_to": "user/2465087832",
            "_rev": "2468364632",
            "_key": "2468364632"
          },
          "vertex": {
            "_id": "user/2462335320",
            "_rev": "3956687192",
            "_key": "2462335320",
            "id": "u1"
          }
        },
        {
          "edge": {
            "_id": "friends/2468102488",
            "_from": "user/2465087832",
            "_to": "user/2462335320",
            "_rev": "2468102488",
            "_key": "2468102488"
          },
          "vertex": {
            "_id": "user/2462335320",
            "_rev": "3956687192",
            "_key": "2462335320",
            "id": "u1"
          }
        }
      ]

Here the answer contains both edge (A to B and B to A) which is correct, but for both the vertex is the one from u1. This three results seem to be inconsistent: for "inbound"/"outbound" : the vertex was u4, and for "any" the vertex is "u1".
Is there a bug in my code? An option that I should use?
If you have any input for me, I would be very grateful!

Thanks,

BobCitron

Wilfried Gösgens

unread,
Sep 22, 2015, 5:02:24 AM9/22/15
to ArangoDB
Please don't double file questions in google groups and stackoverflow.

Bob Citron

unread,
Sep 22, 2015, 5:03:59 AM9/22/15
to ArangoDB
It seems to be a question too specific for stackoverflow, that's why I'm posting it here.

Wilfried Gösgens

unread,
Sep 22, 2015, 5:23:44 AM9/22/15
to ArangoDB
Yes, its actually a bug.
mchacki is currently working on it, stay tuned.

Michael Hackstein

unread,
Sep 22, 2015, 5:54:15 AM9/22/15
to aran...@googlegroups.com
Hi Bob,

thank you very much for spotting this, it is actually a bug in our core.

I did just fix it and it will be included in the next 2.6. bugfix release and in 2.7(devel).
The expected behaviour is as you describe.

Do you actually need the information stored in the Edges?
If not you could consider using the NEIGHBORS function in this case, which is more performant.

best
Michael

--
You received this message because you are subscribed to the Google Groups "ArangoDB" group.
To unsubscribe from this group and stop receiving emails from it, send an email to arangodb+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Xavier P

unread,
Sep 22, 2015, 8:24:02 AM9/22/15
to aran...@googlegroups.com
@Wilfried: Thanks for you quick answer.
@Michael: Thanks for taking a double look at the issue. Nice to help you building this tool :)
 I'll try to use the function NEIGHBORS, edges informations shouldn't be so useful for the moment.

Regards,
Bob Citron

--
You received this message because you are subscribed to a topic in the Google Groups "ArangoDB" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/arangodb/6yIpzLHprrk/unsubscribe.
To unsubscribe from this group and all its topics, send an email to arangodb+u...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages