tinkerpop3

Why do you need to fold/unfold using coalesce for a conditional insert?

左心房为你撑大大i 提交于 2019-11-30 19:13:34
I'm trying to understand how this pattern for a conditional insert works: g.V() .hasLabel('person').has('name', 'John') .fold() .coalesce( __.unfold(), g.addV('person').property('name', 'John') ).next(); What is the purpose of the fold/unfold? Why are these necessary, and why does this not work: g.V() .coalesce( __.hasLabel('person').has('name', 'John'), g.addV('person').property('name', 'John') ).next(); The fold-then-unfold pattern seems redundant to me and yet the above does not yield the same result. Consider what happens when you just do the following: gremlin> g = TinkerFactory

Titan Db ignoring index

人盡茶涼 提交于 2019-11-29 11:35:17
I have a graph with a couple of indices. They're two composite indices with label restraints. (both are exactly the same just on different properties/labels). One definitely seems to work but the other doesn't. I've done the following profile() to doubled check: One is called KeyOnNode : property uid and label node : gremlin> g.V().hasLabel("node").has("uid", "xxxxxxxx").profile().cap(...) ==>Traversal Metrics Step Count Traversers Time (ms) % Dur ============================================================================================================= TitanGraphStep([~label.eq(node), uid

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

佐手、 提交于 2019-11-29 04:43:51
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. With "scripts" you can always pass a multi-line/command script to the server for processing to get what you want done. This question is then answered with normal

Graph/Gremlin for social media use case

自作多情 提交于 2019-11-28 14:24:22
Consider instagram feed scenario. I want to get all the posts 'posted' by the people I follow. For each of these posts I want to know whether I have liked it or not and also know which of the other people I follow have liked it (if any). What is the best solution to get this in gremlin (possibly avoiding duplication)? Image for clarity The following just gives the posts 'posted' by USER 2. How to get other information in the same query? g.V().has('ID','USER 2').out('posted') When you ask questions about Gremlin, especially one of this complexity, it is always best to include a Gremlin script

How to perform pagination in Gremlin

为君一笑 提交于 2019-11-28 11:03:06
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. From a functional perspective, a nice looking bit of Gremlin for paging would be: gremlin> g.V().hasLabel('person').fold().as('persons','count'). select('persons','count'). by(range(local, 0, 2)). by

Titan Db ignoring index

喜欢而已 提交于 2019-11-28 04:33:52
问题 I have a graph with a couple of indices. They're two composite indices with label restraints. (both are exactly the same just on different properties/labels). One definitely seems to work but the other doesn't. I've done the following profile() to doubled check: One is called KeyOnNode : property uid and label node : gremlin> g.V().hasLabel("node").has("uid", "xxxxxxxx").profile().cap(...) ==>Traversal Metrics Step Count Traversers Time (ms) % Dur =============================================

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