0

I want to return only the _id from edges and vertices from the p.path below.

LET from = (
    FOR u IN products
        FILTER u.name == 'pagfr21'
        RETURN u._id
)
FOR p IN TRAVERSAL(products, productsrelated, from[0], 'outbound',
        {minDepth: 0, maxDepth: 3, paths: true})
    RETURN p.path
CodeManX
  • 11,159
  • 5
  • 49
  • 70
Ralf Stein
  • 209
  • 1
  • 12
  • Did the reply suit your needs? If not, whats missing? If, can you mark it closed? – dothebart Nov 24 '15 at 09:20
  • As of Version 2.8 (we're just starting the beta) the [new traversal feature will become available](https://docs.arangodb.com/devel/Aql/GraphTraversals.html) – dothebart Dec 07 '15 at 14:29

1 Answers1

1

Instead of returning p.path you could collect the ids of the vertices and edges subattributes and return them in two separate arrays, e.g.

LET from = (FOR u IN products FILTER u.name == 'foo' RETURN u._id) 

FOR p IN TRAVERSAL(products, productsrelated, from[0], 'outbound', {
  minDepth: 0, 
  maxDepth: 3, 
  paths: true 
}) 

RETURN { 
  vertices: p.path.vertices[*]._id, 
  edges: p.path.edges[*]._id 
}

It will return a structure like this:

[
  {
    "vertices": [
      "products/..."
    ],
    "edges": []
  },
  {
    "vertices": [
      "products/...",
      "products/..."
    ],
    "edges": [
      "productsrelated/..."
    ]
  },
  ...
  {
    "vertices": [
      "products/...",
      "products/...",
      "products/..."
    ],
    "edges": [
      "productsrelated/...",
      "productsrelated/..."
    ]
  }
]
stj
  • 9,037
  • 19
  • 33
  • Has this worked? If yes, would you mind accepting the answer in order to help potential others with the same problem? – stj Sep 03 '15 at 20:24