i have a case that maybe anyone in here can help me to figure out gremlin query in DSE Graph to find path on edge/vertex with multiple properties.
this is my codes in DSE Graph
schema.propertyKey("id").Uuid().ifNotExists().create()`
schema.propertyKey("name").Text().single().create()
schema.propertyKey("vlan").Text().multiple().create()
schema.vertexLabel("site").partitionKey('id').properties("id", "name", "vlan").ifNotExists().create()
schema.edgeLabel("linkTo").multiple().properties("id", "name", "vlan").create()
schema.edgeLabel("linkTo").connection("site","site").add()
schema.vertexLabel("site").index("search").search().by("name").by("vlan").asText().add()
schema.vertexLabel("site").index("siteBySiteId").materialized().by("name").add()
schema.vertexLabel("site").index("toLink").outE("linkTo").by("vlan").add()
schema.vertexLabel("site").index("fromLink").inE("linkTo").by("vlan").add()
AA = graph.addVertex(T.label, 'site', 'id', UUID.randomUUID(), 'name', 'AA', 'vlan', '3353', 'vlan', '3563', 'vlan', '2467')
BB = graph.addVertex(T.label, 'site', 'id', UUID.randomUUID(), 'name', 'BB', 'vlan', '3353', 'vlan', '3563')
CC = graph.addVertex(T.label, 'site', 'id', UUID.randomUUID(), 'name', 'CC', 'vlan', '2467')
DD = graph.addVertex(T.label, 'site', 'id', UUID.randomUUID(), 'name', 'CC', 'vlan', '3353', 'vlan', '3563', 'vlan', '2467')
AA.addEdge('linkTo', BB, 'id', UUID.randomUUID(), 'name', 'AA-BB', 'vlan', '3353', 'vlan', '3563')
AA.addEdge('linkTo', CC, 'id', UUID.randomUUID(), 'name', 'AA-CC', 'vlan', '2467')
BB.addEdge('linkTo', DD, 'id', UUID.randomUUID(), 'name', 'BB-DD', 'vlan', '3353', 'vlan', '3563')
CC.addEdge('linkTo', DD, 'id', UUID.randomUUID(), 'name', 'CC-DD', 'vlan', '2467')`enter code here
--------------------
g.V().
has("site", "name", "AA").
emit().
repeat(timeLimit(200).both("linkTo").
filter(bothE("linkTo").
has("vlan",Search.tokenPrefix("3353"))).
simplePath()).
has("name", "DD").
path().unfold()
but no success :)
So there are a couple of things going on here:
First in your creation script this line has the
nameproperty set toCCinstead ofDDSecond, In Gremlin you cannot add multiproperties (described here) to edges, they are only valid on vertices. As such you will need to change your load script to add parallel edges, one for each
vlanproperty like this:Since you didn't give much detail on what you were trying to get for an answer I inferred that you were looking for all paths from
AAtoDDwhere thevlanis3353. This can be done is a couple of different ways. If you create the parallel edges such as above you can accomplish this using this Gremlin traversal:If you instead decide that you only want to store the
vlanproperty on the vertices you can get that via Gremlin like this:The downside of this is that the
pathwill not contain the edges. If you want the edge information in thepathas well you can change theboth()step to be abothE()/otherV()pattern like this: