user5828171
user5828171

Reputation: 1

How to fetch different number of vertices based on two different conditions in single titan vertex query in java

I want to get the result based on these two conditions in single titan vertex query in java.

Fetch n1 edges with label knows:

v.query().labels('knows').has('id',1).limit(n1)

Fetch n2 edges with label knows:

v.query().labels('knows').has('id',2).limit(n2)

Upvotes: 0

Views: 45

Answers (1)

Daniel Kuppitz
Daniel Kuppitz

Reputation: 10904

You can (and should) use Gremlin queries. The Gremlin query that solves your problem (I assume you're looking for adjacent vertices):

g.V(v).union(both("created").has("id", 1).limit(n1),
             both("created").has("id", 2).limit(n2))

Doesn't make much sense IMO, but you're probably just asking for the query pattern.

Upvotes: 1

Related Questions