DataStax Academy FAQ

DataStax Academy migrated to a new learning management system (LMS) in July 2020. We are also moving to a new Cassandra Certification process so there are changes to exam bookings, voucher system and issuing of certificates.

Check out the Academy FAQ pages for answers to your questions:


question

josef.schauer_169242 avatar image
josef.schauer_169242 asked ·

How to create a result list in gremlin query?

v1= g.V().hasLabel('Vertex1').has('id', '08f0b5d7-5fed-4d00-875d-49cad4d0e9bd').next()
v2= g.V().hasLabel('Vertex2').has('id', '08f0b5d7-5fed-4d00-875d-49cad4d0e9b1').next()

e1 = v1.addEdge('Edge1', v2, T.id, UUID.fromString('18f0b5d7-5fed-4d00-875d-49cad4d0e9b1'), 'date', '2019-06-06')


How can I return the two vertices and the edge in the result list?

graphgremlingraph resultresult
10 |1000 characters needed characters left characters exceeded

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

bryn.cooke_101029 avatar image
bryn.cooke_101029 answered ·

It's worth bearing in mind that the new Core graph engine does not support calling 'Vertex#addEdge' and you will get a message: Edge additions not supported.

You should use something like this to add edges:

g.addV('person').property('name', 'bob').as('person').
  addV('software').property('name', 'Studio').as('software').
  addE('created').from('person').to('software').as('created')

The advantage of the above is that it doesn't require a read before write and will be much faster. This will also work in `Classic` graphs.

For your purposes you can the use 'select' to get back the original elements:

g.addV('person').property('name', 'bob').as('person').
  addV('software').property('name', 'Studio').as('software').
  addE('created').from('person').to('software').as('created').
  select('person','software', 'created')

==>{person=v[person:bob#64], software=v[software:Studio#05], created=e[person:bob#64->created#96->software:Studio#05][person:bob#64-created->software:Studio#05]}


1 comment Share
10 |1000 characters needed characters left characters exceeded

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

But the read is important in this example, because I want to create an edge between two already existing vertices.

How this would be solved for the new Core Graph Engine?

0 Likes 0 · ·
josef.schauer_169242 avatar image
josef.schauer_169242 answered ·

But the read is important in this example, because I want to create an edge between two already existing vertices.

How this would be solved for the new Core Graph Engine?

1 comment Share
10 |1000 characters needed characters left characters exceeded

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

Thanks for choosing DataStax! Just a friendly note since we're all new here but this is really a "comment" rather than an "answer". Just a friendly advice for those who come across "answers" in the future. Cheers! :)

0 Likes 0 · ·
josef.schauer_169242 avatar image
josef.schauer_169242 answered ·

found the very simple Solution: [v1, v2, e1]

Share
10 |1000 characters needed characters left characters exceeded

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