[Neo4j] Gremlin syntax for multiple paths in one call

Peter Neubauer peter.neubauer at neotechnology.com
Tue Oct 4 17:31:04 CEST 2011


Nice one, will change the docs.

/peter

Sent from my phone.
On Oct 4, 2011 5:20 PM, "Marko Rodriguez" <okrammarko at gmail.com> wrote:
> Hey,
>
>> If I want to get the following
>>
>> g.V(0).out('Friends')
>>
>> and
>>
>> g.V(0).in('Likes')
>
>
> This is the world of split and merge. The syntax for this is not the
sexiest, but as it stands:
>
> g.v(0)._.copySplit(_().out('Friends'), _().in('Likes')).fairMerge
>
> copySplit will take what comes into it and copy it to its internal pipes
(in this case, 2 internal pipes). Then fairMerge will, in a round robin
fashion, merge the output of the two internal pipes into a single pipe.
Thus, split the pipeline, then merge it back into a single pipeline.
>
> For example, over the play TinkerPop graph:
>
> gremlin> g = TinkerGraphFactory.createTinkerGraph()
> ==>tinkergraph[vertices:6 edges:6]
> gremlin> g.v(1)._.copySplit(_().out('created'),_().out('knows')).fairMerge
> ==>v[3]
> ==>v[2]
> ==>v[4]
>
> We haven't developed split/merge much. If you have any ideas for syntax,
that'd be great.
>
> NOTE: If they were both out, then you can simply do:
g.v(0).out('friends','likes')
>
> Good luck,
> Marko.
>
> http://markorodriguez.com
> _______________________________________________
> Neo4j mailing list
> User at lists.neo4j.org
> https://lists.neo4j.org/mailman/listinfo/user


More information about the User mailing list