How to print out Gremlin pipe / traversal results

前端 未结 2 1199
春和景丽
春和景丽 2021-01-22 16:09

I have the code below in a file named traversal.groovy (which I call from the command line with gremlin -e traversal.groovy):

// Beg         


        
相关标签:
2条回答
  • 2021-01-22 16:27

    You likely just need to iterate your pipeline:

    http://gremlindocs.com/#methods/pipe-next

    println v.outE.inV.name.next()
    
    0 讨论(0)
  • 2021-01-22 16:32

    Thanks to stephen mallette for pointing me in the right direction. To simply print out the "name" property of each vertex in my traversal above, we can use sideEffect and iterate. The resulting code would look as follows:

    // Begin traversal.groovy //
    
    g = TinkerGraphFactory.createTinkerGraph()
    v = g.v(1)
    
    v.outE.inV.sideEffect{println it.name}.iterate()
    
    // End traversal.groovy //
    

    and the output would be:

    vadas
    josh
    lop
    
    0 讨论(0)
提交回复
热议问题