Nischal Kumar
Nischal Kumar

Reputation: 522

Tinkerpop Gremlin: Batching of multiple select query into one batch select query

In Tinkerpop Gremlin, I have two select query

  1. g.V().has("id","foo").out().values("x").toList();
  2. g.V().has("bar","foo").out().values("id").toList();

Now Can we club these query into one batched tinkerpop gremlin? I tried g.V().has("id","foo").out().values("x").union(__.V().has("bar","foo").out().values("id")).toList()

but this leads to a single list instead of two separate list. I want to extract the response of these two queries separately.

Upvotes: 0

Views: 410

Answers (1)

stephen mallette
stephen mallette

Reputation: 46206

You could start your traversal with some dummy value and then union() the two traversals together:

gremlin> g.inject(0).union(V(1).out().fold(),V(2).in().fold())
==>[v[3],v[2],v[4]]
==>[v[1]]

Upvotes: 1

Related Questions