0

I need to start with one vertex and find all the related vertices till end. Criteria is to match any one of the edge properties(attributes) in the edge inV vertex. If edge attribute ‘value’ doesn’t match inV vertex ‘attribute’ name I should skip the vertex. Attribute value of edge is propagated as Attribute name in the inV vertex

Am using below query, however this gives me json output of parent node, next node and edges between. With the output am writing logic to pick only next attributes which match with the edge attributes. If the matching of attributes can be done with gremlin query, that would be great

var graphQuery = "g.V().has('sPath', '/Assisted/CSurvey/CSurvey.ss').as('ParentStream').outE.inV().as('Edges').map(select('Edges').inV().fold()).as ('NextStream').select('ParentStream', 'NextStream','Edges')";

In below/attached image. I need to get vertex1 and vertex2 and skip vertex3 as there are no attributes matching with edge image link

Vamsee S
  • 11
  • 3
  • 2
    Note my recommendation here: https://stackoverflow.com/a/51337481/1831717 to provide a Gremlin script that provides some sample data to work with. Frame your question in the context of that sample data....It makes it much easier to answer questions. – stephen mallette Jul 15 '18 at 23:19

1 Answers1

0

Use graph traversal and filter

Example in Scala:

graph.traversal().V().has().bothE('sPath').filter{it:Edge =>
(it.property('sPath').value() == '/Assisted/CSurvey/CSurvey.ss')}.toList()

Hope this helps

PGS
  • 1,046
  • 2
  • 17
  • 38
  • Thanks for response, however i am trying to run the gremlin query via azure data explorer on cosmos db or via thinker pop3 gremlin console and am seeing below error. do we need to any additional installs to support lambdas in gremlin query . Do we have any alternate way of writing this same query Error: Script compile error: Unexpected token: '>'; in input: V().has().bothE('sPath').filter{it:Edge=> – Vamsee S Jul 20 '18 at 02:16