What's the correct way to find vertices with a certain property values?

45 views
Skip to first unread message

Andy

unread,
Oct 1, 2015, 10:40:24 AM10/1/15
to Gremlin-users
Hi all,

I am new to tinkerpop 3 and I am trying to do the traversal via Java API. I tried the following but they didn't work for me.

g.V().has("type", Arrays.toList(types));

g.V().has("type").hasValue(types);

What should be the correct traversal code?

Thank you.

Regards,
Andy

Jason Plurad

unread,
Oct 1, 2015, 11:01:53 AM10/1/15
to Gremlin-users
use within()

gremlin> graph = TinkerFactory.createClassic()
==>tinkergraph[vertices:6 edges:6]
gremlin
> g = graph.traversal()
==>graphtraversalsource[tinkergraph[vertices:6 edges:6], standard]
gremlin
> g.V().out().has('name', within('vadas','josh'))
==>v[2]
==>v[4]
gremlin> l = ['vadas', 'josh']
==>vadas
==>josh
gremlin
> g.V().out().has('name', within(l))
==>v[2]
==>v[4]

Andy

unread,
Oct 1, 2015, 7:52:32 PM10/1/15
to Gremlin-users
Ah, thank you so much. I was thinking about this within() method and couldn't find it in the GraphTraversal and found out I was looking at the wrong place. It's actually under the P class.

Stupid me.

Thanks again.
Reply all
Reply to author
Forward
0 new messages