Created
          November 5, 2018 10:08 
        
      - 
      
 - 
        
Save garymacindoe/22179da58a3defb0520b61624d4e7002 to your computer and use it in GitHub Desktop.  
    Query to change the ID of a vertex using Gremlin
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | g.V() | |
| // Find (single) vertex to change | |
| .as('old') | |
| .addV(select('old').label()) | |
| .as('new') | |
| .property(id, new_id) // Insert new ID for vertex here | |
| .sideEffect( | |
| select('old') | |
| .properties() | |
| .unfold() | |
| .as('p') | |
| .select('new') | |
| .property( | |
| select('p').key(), | |
| select('p').value() | |
| ) | |
| ) | |
| .sideEffect( | |
| select('old') | |
| .inE() | |
| .unfold() | |
| .as('in') | |
| .outV() | |
| .addE(select('in').label()) | |
| .to('new') | |
| .as('new') | |
| .select('in') | |
| .properties() | |
| .unfold() | |
| .as('p') | |
| .select('new') | |
| .property( | |
| select('p').key(), | |
| select('p').value() | |
| ) | |
| ) | |
| .sideEffect( | |
| select('old') | |
| .outE() | |
| .unfold() | |
| .as('out') | |
| .inV() | |
| .addE(select('out').label()) | |
| .from('new') | |
| .as('new') | |
| .select('out') | |
| .properties() | |
| .unfold() | |
| .as('p') | |
| .select('new') | |
| .property( | |
| select('p').key(), | |
| select('p').value() | |
| ) | |
| ) | |
| .select('old').drop() | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment