Search code examples
javagremlintinkerpopamazon-neptune

Drop in Netpune Gremlin Session Query


Can the "drop()" query work in a Session client in Gremlin queries in Java for AWS Neptune. I have tried a few times but the "drop()" only works if I use iterate() and does not have any effect is the session client is used and query is submitted.

If it does work, it will be helpful to have some examples. It is not very clear from the documentation.


Solution

  • I tried some experiments using the Gremlin Console in "session mode". Note that the transaction will only commit once the session is closed.

    $ bin/gremlin.sh
    
             \,,,/
             (o o)
    -----oOOo-(3)-oOOo-----
    plugin activated: tinkerpop.server
    plugin activated: tinkerpop.utilities
    plugin activated: tinkerpop.tinkergraph
    gremlin> :remote connect tinkerpop.server conf/krl6w.yaml session abc-123
    ==>Configured xxxx-[abc-123]
    
    gremlin> :remote console
    ==>All scripts will now be sent to Gremlin Server - [xxx]-[abc-123] - type ':remote console' to return to local mode
    
    gremlin> g.V().hasLabel('airport').count()
    ==>3503
    
    gremlin> g.V().hasLabel('airport').drop()
    
    gremlin> g.V().hasLabel('airport').count()
    ==>0
    
    // This ends the session and commits the transaction
    gremlin> :remote close
    
    

    Now to verify it worked

    gremlin> :remote connect tinkerpop.server conf/krl6w.yaml
    ==>Configured xxxx
    
    gremlin> :remote console
    ==>All scripts will now be sent to Gremlin Server - [xxxxx:8182] - type ':remote console' to return to local mode
    
    gremlin> g.V().hasLabel('airport').count()
    ==>0