question

josef.schauer_169242 avatar image
josef.schauer_169242 asked bettina.swynnerton commented

DSE 6.8 Graph: Edge MetaInformation and Properties in one Result

Hello,


In my query I traverse to an edge. The result must contain the meta information of the edge (inV(), outV(), ...) and the properties.


schema

schema.vertexLabel('Vertex1').ifNotExists().partitionBy('id', UUID).create()
schema.vertexLabel('Vertex2').ifNotExists().partitionBy('id', UUID).create()

schema.edgeLabel('Edge').
  ifNotExists().
  from('Vertex1').to('Vertex2').
  property('id', UUID).
  property('property1', Text).
  property('property2', Text).
  create()


data

g.addV('Vertex1').property('id', '1dacdea2-24aa-440d-a130-2c1b06ffed13' as UUID).next()
g.addV('Vertex2').property('id', '9673a3bb-8d94-40fe-9e27-c11c3edb56b7' as UUID).next()


g.V().hasLabel('Vertex1').has('id', '1dacdea2-24aa-440d-a130-2c1b06ffed13' as UUID).as('v1')
.V().hasLabel('Vertex2').has('id', '9673a3bb-8d94-40fe-9e27-c11c3edb56b7' as UUID).as('v2')
.addE('Edge')
.property('id', UUID.randomUUID())
.property('property1', 'Text1')
.property('property2', 'Text2')
.from('v1').to('v2')


query (not working, very simple version)


g.E().project('in', 'out', 'properties')
.by(inV())
.by(outV())
.by(properties())


result

{
  "in": {
    "id": "dseg:/Vertex2/9673a3bb-8d94-40fe-9e27-c11c3edb56b7",
    "label": "Vertex2",
    "type": "vertex",
    "properties": {}
  },
  "out": {
    "id": "dseg:/Vertex1/1dacdea2-24aa-440d-a130-2c1b06ffed13",
    "label": "Vertex1",
    "type": "vertex",
    "properties": {}
  },
  "properties": {
    "key": "property2",
    "value": "Text2"
  }
}


As you can see in the result, I get the information of the in and out Vertex, but the properties are not complete.


What are the correct steps to get this information in one result entry?


Thanks in Advance

Josef


dsegraph
10 |1000

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

1 Answer

bettina.swynnerton avatar image
bettina.swynnerton answered bettina.swynnerton commented

Hi @josef.schauer_169242,

you could project a valueMap():

g.E().project('in', 'out', 'properties')
.by(inV())
.by(outV())
.by(valueMap())

The new elementMap() step might also give you the information that you need.

Here for your example graph (again, thank you for schema and data), in gremlin console:

gremlin> g.E().elementMap()
[warn] This traversal could read elements without a label restriction.
This may degrade performance if many element labels are involved. Suggestions:
 - Add hasLabel steps to the traversal where vertices are read or edges traversed.  Examples:
     Instead of V(), use V().hasLabel('vertex_label')
     Instead of out(), use out('edge_label')
 - Suppress this warning by beginning the traversal by g.with("label-warning", false).
==>{id=dseg:/Vertex1-Edge-Vertex2/1dacdea2-24aa-440d-a130-2c1b06ffed13/9673a3bb-8d94-40fe-9e27-c11c3edb56b7, label=Edge, IN={id=dseg:/Vertex2/9673a3bb-8d94-40fe-9e27-c11c3edb56b7, label=Vertex2, id=9673a3bb-8d94-40fe-9e27-c11c3edb56b7}, OUT={id=dseg:/Vertex1/1dacdea2-24aa-440d-a130-2c1b06ffed13, label=Vertex1, id=1dacdea2-24aa-440d-a130-2c1b06ffed13}, property2=Text2, property1=Text1, id=6e29f5f5-16d9-49f5-9709-4c8ea3d0fc76}

However, I noticed that the new step does not yet render results in Studio, I have raised this with the Studio team. It should work through the drivers though. Which driver are you using?

4 comments Share
10 |1000

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

josef.schauer_169242 avatar image josef.schauer_169242 commented ·

Driver:

com.datastax.oss:java-driver-core:4.7.2


It seems that version 6.8.0 and 6.8.1 is still a bit unstable.


Does it make sense to use it already? (of course, you have to answer with yes)

But try to give me an honest answer.

0 Likes 0 ·
bettina.swynnerton avatar image bettina.swynnerton ♦♦ josef.schauer_169242 commented ·

Hi @josef.schauer_169242,

yes, I definitely want to give you an honest answer. :)

To be fair, what you report here is not an instability of DSE Graph 6.8.x. I agree that Studio 6.8.1 does not render the result correctly, but this is not itself an issue with the Graph engine.

DSE Graph 6.8.x introduced a new Graph engine. 6.8.1 is obviously still an early release in the branch, but it has been tested extensively and cleared for GA. It is not released with known instabilities, and if you find issues, we definitely want to know about them.

In terms of Graph capabilities, DSE Graph 6.8 core graph engine has very significant advantages over the previous version, and I would say, yes, I think it makes sense to use it.

Does this answer your question?

1 Like 1 ·
josef.schauer_169242 avatar image josef.schauer_169242 bettina.swynnerton ♦♦ commented ·

yes, thanks for the honest answer.

0 Likes 0 ·
Show more comments