despotbg
despotbg

Reputation: 778

Gremlin query like SQL IN operator?

Im stuck with gremlin. I have emails like array and I need to make query to find all user with those emails.

In SQL I have

SELECT email(s)
FROM user
WHERE email IN (xxx, yyy...)

How can I do this in Gremlin query language?

Upvotes: 3

Views: 2404

Answers (3)

Abhilash Menon
Abhilash Menon

Reputation: 56

What you wanna do here is:

g.V().has('anyProperty', within('possibleValue1', 'possibleValue2'))

Upvotes: 4

Priyadarshini Ravi
Priyadarshini Ravi

Reputation: 57

g.V('table_name','User').has('email',IN,[xxx,yyy....]).transform({['email':it.getProperty('email')]}) //assuming u have a table name attribute

Upvotes: 0

stephen mallette
stephen mallette

Reputation: 46226

If it is acceptable for you to do a linear scan of all vertices, then you could do something like:

gremlin> g = TinkerGraphFactory.createTinkerGraph()
==>tinkergraph[vertices:6 edges:6]
gremlin> s = ['marko','josh'] as Set
==>marko
==>josh
gremlin> g.V.filter{s.contains(it.name)}.name
==>marko
==>josh

Upvotes: 0

Related Questions