Gremlin - only add a vertex if it doesn't exist
问题 I have an array of usernames (eg. ['abc','def','ghi'] ) to be added under 'user' label in the graph. Now I first want to check if the username already exists ( g.V().hasLabel('user').has('username','def') ) and then add only those for which the username property doesn't match under 'user' label. Also, can this be done in a single gremlin query or groovy script? I am using titan graph database, tinkerpop3 and gremlin REST server. 回答1: With "scripts" you can always pass a multi-line/command