You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tinkerpop.apache.org by Marko Rodriguez <ok...@gmail.com> on 2015/02/05 21:59:24 UTC

[TinkerPop3] AndStep, OrStep, and Logical Operator Overloads in GremlinSugarPlugin

Hello,

Last week Daniel and I worked on AndStep and OrStep. These are both filter-steps and can be used in two ways.

	1. and(x,y)  …   or(x,y)  --- prefix notation
        2. x.and.y    …   x.or.y   --- infix notation

The benefit of the later is with Groovy support of Object.or() and Object.and() overloading in SugarPlugin, you can do things like this:

	g.V.has(outE('created') & inE('knows')).name
		"Give me the name of a person that both created something and is known by someone."

You can get as crazy as you want with nested and'ing and or'ing:

g.V().and(
       inE().count().is(gte,1l), 
       has(label, 'person').or().has('age', gte, 32)).
      values('name')

Finally, here are some docs:

	AndStep:        http://www.tinkerpop.com/docs/3.0.0-SNAPSHOT/#and-step
	OrStep:           http://www.tinkerpop.com/docs/3.0.0-SNAPSHOT/#or-step
	SugarPlugin:	 http://www.tinkerpop.com/docs/3.0.0-SNAPSHOT/#sugar-plugin

Enjoy,
Marko.

http://markorodriguez.com