specimen February 2016

Negative filterVertices option for traversal

The GRAPH_TRAVERSAL has an option called filterVertices, which the documentation states will be used to only allow those vertices matching the examples to go through. Is there any negative version of this, e.g. to allow everything except those matching the filter?

In many cases this would be useful, e.g. traverse everything except those marked disabled (or old-version) or something like that. Of course this can be done with a JS function, but why not built-in?


dothebart February 2016

You're right, its currently not possible, and if you want to use GRAPH_TRAVERSAL you have to write your own visitor function.

However, the recommended way is to use the new pattern matching where you can use FILTER statements like this:

db._query("FOR vertex IN 1..3 OUTBOUND 'circles/A' GRAPH
          'traversalGraph' FILTER vertex._key != 'G' return v._key")

so you can use arbitrary filter expressions on vertices, edges and paths and their sub-parts.

In general our development focus will be on the pattern matching traversals and doing as much as is possible in AQL. If you like to implement such a feature for the general graph module, Contributions are always welcome.

Post Status

Asked in February 2016
Viewed 3,337 times
Voted 14
Answered 1 times


Leave an answer