Gremlin query like SQL IN operator?

怎甘沉沦 提交于 2019-12-24 12:20:04

问题


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?


回答1:


What you wanna do here is:

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



回答2:


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



回答3:


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



来源:https://stackoverflow.com/questions/16273667/gremlin-query-like-sql-in-operator

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!