gremlin

Gremlin - only add a vertex if it doesn't exist

左心房为你撑大大i 提交于 2019-11-28 01:09:12
问题 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

How to perform pagination in Gremlin

假装没事ソ 提交于 2019-11-26 21:34:30
问题 In Tinkerpop 3, how to perform pagination? I want to fetch the first 10 elements of a query, then the next 10 without having to load them all in memory. For example, the query below returns 1000,000 records. I want to fetch them 10 by 10 without loading all the 1000,000 at once. g.V().has("key", value).limit(10) Edit A solution that works through HttpChannelizer on Gremlin Server would be ideal. 回答1: From a functional perspective, a nice looking bit of Gremlin for paging would be: gremlin> g