How to use a Predicate in the "Has" step?

492 views
Skip to first unread message

pShah

unread,
Mar 11, 2016, 12:01:07 AM3/11/16
to Gremlin-users
Hi,
  Shown below is the code I am trying and not getting anywhere, must be missing something simple.


Tried writing some code similar to what I saw in documentation: http://tinkerpop.apache.org/docs/3.1.1-incubating/reference/#has-step
g.V().has('name',not(within('josh','marko'))).valueMap() //(5)

Version:'3.1.1-incubating'

Code:
import org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerFactory
import spock.lang.Specification

class SampleTest extends Specification {
def findMultiple() {
def graph = TinkerFactory.createModern();
def g = graph.traversal()

expect:
g.V().has("name", within("marko", "vadas")).count() == 2
}
}

Error:
groovy.lang.MissingMethodException: No signature of method: SampleTest.within() is applicable for argument types: (java.lang.String, java.lang.String) values: [marko, vadas]
Possible solutions: with(java.lang.Object, groovy.lang.Closure), with(groovy.lang.Closure), wait(), with(java.lang.Object, java.lang.Class, groovy.lang.Closure)

at SampleTest.findMultiple(SampleTest.groovy:10)


Any help would be great.

Thanks.

Daniel Kuppitz

unread,
Mar 11, 2016, 9:02:43 AM3/11/16
to gremli...@googlegroups.com
First be sure to static import P.*, next you'll also need to make it .count().next(), otherwise it's just a traversal, which can't never be equal to 2.

Cheers,
Daniel


--
You received this message because you are subscribed to the Google Groups "Gremlin-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to gremlin-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/gremlin-users/cee30d0b-cd3b-4eaf-a540-85fbd8b03cf2%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

pShah

unread,
Mar 11, 2016, 2:08:08 PM3/11/16
to Gremlin-users
Thanks, I knew I was missing something.
Reply all
Reply to author
Forward
0 new messages