0

I am using gremlin query to search for vertices from a given vertex.

v.both("edgeLabel").has("propertykey", "27826345");

This query is returning a bunch of vertices. Now I am creating edges from 'v' to all those returned vertices by simple iterator.

Now my question is:
Is there any process/query style available through which I can search for those vertices and create edges in the same query ?

I have already tried this query:

 v.both('edgeLabel').has('propertykey','27826345').gather(){g.addEdge(v,it,'TEST_LABEL')}

But I'm getting error :

No signature of method: groovy.lang.MissingMethodException.addEdge()

I am currently using Gremlin-Groovy ScriptEngine to execute my query from a Java class.

Thank you in Advance.

Pradatta
  • 3,000
  • 1
  • 18
  • 22

2 Answers2

1

In Gremlin 2.3.0, there are three new steps:

 linkIn
 linkOut
 linkBoth

Please see GremlinDocs (http://gremlindocs.com) for more information on how to use them.

http://gremlindocs.com/#transform/linkboth-in-out

Note that these pipes yield a sideEffect (the edge generated) so you can cap the pipe if you need to get the edge.

Marko A. Rodriguez
  • 1,702
  • 12
  • 13
  • Thank you very much for your response. Actually I was using Gremlin 2.2.0, probably that's why I over-looked/missed that ..Anyway thank you once again for helping me out. – Pradatta May 07 '13 at 17:52
0

You probably need to provide an id to addEdge. Here are the javadocs.

v.both('edgeLabel').has('propertykey','27826345').gather(){g.addEdge(1,v,it,'TEST_LABEL')}

zmaril
  • 296
  • 2
  • 7
  • Well from Blueprint API I usually send null for the ID field, so that framework can automatically create it's own ID. But for Gremlin Query I long as I know there's two method one without id, and one with id parameter. http://gremlindocs.com/#methods/graph-addedge – Pradatta May 07 '13 at 06:01