specimen
specimen

Reputation: 1765

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?

Upvotes: 0

Views: 48

Answers (1)

dothebart
dothebart

Reputation: 6067

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")
         .toArray();

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.

Upvotes: 1

Related Questions