0
votes

I'm having trouble constructing the gremlin query to give me all of the Edge details(label, properties) and also the ID's of the Inv and OutV adjoining Vertex's (I don't need any more info from the linked Vertex's, just the ID's).

All I have is the Edge ID as a starting point.

So my Edge is as follows:

Label: "CONTAINS"
id: c6b4f3cb-f96e-cc97-dedb-e405771cb4f2
keys:
key="ekey1", value="e1"
key="ekey2", value="e2"

inV has id 50b4f3cb-f907-c31c-6284-1a3463fd72b9

outV has id 7cb4f3cb-d9a2-1398-61d7-9339be34833b

What I want is a single query that will return me something like -

"CONTAINS", "c6b4f3cb-f96e-cc97-dedb-e405771cb4f2", {ekey1=e1, ekey2=e2, ...}, "50b4f3cb-f907-c31c-6284-1a3463fd72b9", "7cb4f3cb-d9a2-1398-61d7-9339be34833b"

I can get the info in separate queries i.e.

g.E("c6b4f3cb-f96e-cc97-dedb-e405771cb4f2").bothV()
==>v[50b4f3cb-f907-c31c-6284-1a3463fd72b9]
==>v[7cb4f3cb-d9a2-1398-61d7-9339be34833b]
g.E("c6b4f3cb-f96e-cc97-dedb-e405771cb4f2").valueMap()
==>{ekey1=e1, ekey2=e2}
g.E("c6b4f3cb-f96e-cc97-dedb-e405771cb4f2").label()
==>CONTAINS

But I can't for the life of me work out how to combine these into one.

1

1 Answers

2
votes

You could use project() to get what you're looking for:

g.E("c6b4f3cb-f96e-cc97-dedb-e405771cb4f2").
  project('ekey1', 'inV', 'outV', 'label').
    by('ekey1').
    by(inV().id()).
    by(outV().id()).
    by(label).