Dynamic edge creation


Ankur Goel <ankur...@...>
 

Thnx Robert, it helped big time.


On Friday, September 15, 2017 at 3:02:46 PM UTC+5:30, Ankur Goel wrote:
Hi,

 In JanusGraph to create edges we have two steps process:
  1. First identify the vertex
  2. Then create edges between vertex
Linkage between both steps is through App only.

How ever in neo4j, we can create edges using one step:

MATCH (a:player), (b:Country) WHERE a.POB = "X" AND b.name = "Y" 
CREATE (a)-[r: Z]->(b) 
RETURN a,b

Can we achieve the same in JanusGraph using Janus or tinkerpoop.

~AnkurG


Robert Dale <rob...@...>
 


Change `outE()` to `bothE()` since you don't care about direction.


On Monday, September 18, 2017 at 6:21:59 AM UTC-4, Robert Dale wrote:
If `l1` is `p1` then yes, this will create an edge from every player p1 to every player p2. You're not filtering anything out so all players show up in both `V().hasLabel('player')`.  If you want to filter out `self` and `has existing 'sameTeam' edge, try this:

g.V().hasLabel('player').as('p1').V().hasLabel('player').where(neq('p1')).where(eq('p1')).by('teamName').not(outE('sameTeam')).addE('sameTeam').from('p1')

Robert Dale

On Mon, Sep 18, 2017 at 1:58 AM, Ankur Goel <ankur...@...> wrote:
Thnx Robert n Daniel,

Its working like charm. But it got stuck in other use case:

where i want to create relation based on team:

g.V().hasLabel('player').as('p1').V().hasLabel('player').where(eq('l1')).by('teamName').addE('sameTeam').from('p1')

in this i want to create edges between same teamName player.

Above gremlin query is working but creating all combination of edges. For example for a 3 node of player label  having same team name, its creating 9 edges, instead of 3 only. Double edges for between two vertex and one loop to same vertex.

~AnkurG


On Fri, Sep 15, 2017 at 7:54 PM, Daniel Kuppitz <me@...> wrote:
Oops, Gmail didn't notify me about your response, sorry for the double-post.

On Fri, Sep 15, 2017 at 6:57 AM, Robert Dale <rob...@...> wrote:

g.V().hasLabel('player').as('player').V().hasLabel('Country').where(eq('player')).by('name').by('POB').addE('Z').from('player')

Robert Dale

On Fri, Sep 15, 2017 at 9:44 AM, Ankur Goel <ankur...@...> wrote:
Thnx Robert,

i am looking for a query like create edges where they have common properties without explicitly defining properties values:

g.V().has('player','POB',${A}).as('a').V().has('Country','name',{B}).addE('Z').from('a').where(${A} = ${B})

~AnkurG




On Friday, September 15, 2017 at 3:02:46 PM UTC+5:30, Ankur Goel wrote:
Hi,

 In JanusGraph to create edges we have two steps process:
  1. First identify the vertex
  2. Then create edges between vertex
Linkage between both steps is through App only.

How ever in neo4j, we can create edges using one step:

MATCH (a:player), (b:Country) WHERE a.POB = "X" AND b.name = "Y" 
CREATE (a)-[r: Z]->(b) 
RETURN a,b

Can we achieve the same in JanusGraph using Janus or tinkerpoop.

~AnkurG

--
You received this message because you are subscribed to the Google Groups "JanusGraph users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to janusgraph-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/janusgraph-users/06575748-b6cc-4f1a-aeac-cd76b9cb5b28%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "JanusGraph users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to janusgraph-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/janusgraph-users/CABed_4q6%3DB%2BNPgu-QgFETS1fjckAVF%3DbVCWMnaT7%3Dyq1o6eCpg%40mail.gmail.com.

For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to a topic in the Google Groups "JanusGraph users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/janusgraph-users/7Cn4G__XGjU/unsubscribe.
To unsubscribe from this group and all its topics, send an email to janusgraph-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/janusgraph-users/CA%2Bf9seVEwxs2%2BHFmQV-8mJ_2LU79tjkAJ5AeorsH%3De2PtLwk4g%40mail.gmail.com.

For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "JanusGraph users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to janusgraph-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/janusgraph-users/CAFDtHAns%3Do9iTrB7q8w%2Bz%2BWvuQvcf9KXnfyOgg2JRGnVg-0sQQ%40mail.gmail.com.

For more options, visit https://groups.google.com/d/optout.


Robert Dale <rob...@...>
 

If `l1` is `p1` then yes, this will create an edge from every player p1 to every player p2. You're not filtering anything out so all players show up in both `V().hasLabel('player')`.  If you want to filter out `self` and `has existing 'sameTeam' edge, try this:

g.V().hasLabel('player').as('p1').V().hasLabel('player').where(neq('p1')).where(eq('p1')).by('teamName').not(outE('sameTeam')).addE('sameTeam').from('p1')

Robert Dale

On Mon, Sep 18, 2017 at 1:58 AM, Ankur Goel <ankur...@...> wrote:
Thnx Robert n Daniel,

Its working like charm. But it got stuck in other use case:

where i want to create relation based on team:

g.V().hasLabel('player').as('p1').V().hasLabel('player').where(eq('l1')).by('teamName').addE('sameTeam').from('p1')

in this i want to create edges between same teamName player.

Above gremlin query is working but creating all combination of edges. For example for a 3 node of player label  having same team name, its creating 9 edges, instead of 3 only. Double edges for between two vertex and one loop to same vertex.

~AnkurG


On Fri, Sep 15, 2017 at 7:54 PM, Daniel Kuppitz <me@...> wrote:
Oops, Gmail didn't notify me about your response, sorry for the double-post.

On Fri, Sep 15, 2017 at 6:57 AM, Robert Dale <rob...@...> wrote:

g.V().hasLabel('player').as('player').V().hasLabel('Country').where(eq('player')).by('name').by('POB').addE('Z').from('player')

Robert Dale

On Fri, Sep 15, 2017 at 9:44 AM, Ankur Goel <ankur...@...> wrote:
Thnx Robert,

i am looking for a query like create edges where they have common properties without explicitly defining properties values:

g.V().has('player','POB',${A}).as('a').V().has('Country','name',{B}).addE('Z').from('a').where(${A} = ${B})

~AnkurG




On Friday, September 15, 2017 at 3:02:46 PM UTC+5:30, Ankur Goel wrote:
Hi,

 In JanusGraph to create edges we have two steps process:
  1. First identify the vertex
  2. Then create edges between vertex
Linkage between both steps is through App only.

How ever in neo4j, we can create edges using one step:

MATCH (a:player), (b:Country) WHERE a.POB = "X" AND b.name = "Y" 
CREATE (a)-[r: Z]->(b) 
RETURN a,b

Can we achieve the same in JanusGraph using Janus or tinkerpoop.

~AnkurG

--
You received this message because you are subscribed to the Google Groups "JanusGraph users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to janusgraph-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/janusgraph-users/06575748-b6cc-4f1a-aeac-cd76b9cb5b28%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "JanusGraph users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to janusgraph-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/janusgraph-users/CABed_4q6%3DB%2BNPgu-QgFETS1fjckAVF%3DbVCWMnaT7%3Dyq1o6eCpg%40mail.gmail.com.

For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to a topic in the Google Groups "JanusGraph users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/janusgraph-users/7Cn4G__XGjU/unsubscribe.
To unsubscribe from this group and all its topics, send an email to janusgraph-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/janusgraph-users/CA%2Bf9seVEwxs2%2BHFmQV-8mJ_2LU79tjkAJ5AeorsH%3De2PtLwk4g%40mail.gmail.com.

For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "JanusGraph users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to janusgraph-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/janusgraph-users/CAFDtHAns%3Do9iTrB7q8w%2Bz%2BWvuQvcf9KXnfyOgg2JRGnVg-0sQQ%40mail.gmail.com.

For more options, visit https://groups.google.com/d/optout.


Ankur Goel <ankur...@...>
 

Thnx Robert n Daniel,

Its working like charm. But it got stuck in other use case:

where i want to create relation based on team:

g.V().hasLabel('player').as('p1').V().hasLabel('player').where(eq('l1')).by('teamName').addE('sameTeam').from('p1')

in this i want to create edges between same teamName player.

Above gremlin query is working but creating all combination of edges. For example for a 3 node of player label  having same team name, its creating 9 edges, instead of 3 only. Double edges for between two vertex and one loop to same vertex.

~AnkurG


On Fri, Sep 15, 2017 at 7:54 PM, Daniel Kuppitz <me@...> wrote:
Oops, Gmail didn't notify me about your response, sorry for the double-post.

On Fri, Sep 15, 2017 at 6:57 AM, Robert Dale <rob...@...> wrote:

g.V().hasLabel('player').as('player').V().hasLabel('Country').where(eq('player')).by('name').by('POB').addE('Z').from('player')

Robert Dale

On Fri, Sep 15, 2017 at 9:44 AM, Ankur Goel <ankur...@...> wrote:
Thnx Robert,

i am looking for a query like create edges where they have common properties without explicitly defining properties values:

g.V().has('player','POB',${A}).as('a').V().has('Country','name',{B}).addE('Z').from('a').where(${A} = ${B})

~AnkurG




On Friday, September 15, 2017 at 3:02:46 PM UTC+5:30, Ankur Goel wrote:
Hi,

 In JanusGraph to create edges we have two steps process:
  1. First identify the vertex
  2. Then create edges between vertex
Linkage between both steps is through App only.

How ever in neo4j, we can create edges using one step:

MATCH (a:player), (b:Country) WHERE a.POB = "X" AND b.name = "Y" 
CREATE (a)-[r: Z]->(b) 
RETURN a,b

Can we achieve the same in JanusGraph using Janus or tinkerpoop.

~AnkurG

--
You received this message because you are subscribed to the Google Groups "JanusGraph users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to janusgraph-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/janusgraph-users/06575748-b6cc-4f1a-aeac-cd76b9cb5b28%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "JanusGraph users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to janusgraph-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/janusgraph-users/CABed_4q6%3DB%2BNPgu-QgFETS1fjckAVF%3DbVCWMnaT7%3Dyq1o6eCpg%40mail.gmail.com.

For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to a topic in the Google Groups "JanusGraph users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/janusgraph-users/7Cn4G__XGjU/unsubscribe.
To unsubscribe from this group and all its topics, send an email to janusgraph-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/janusgraph-users/CA%2Bf9seVEwxs2%2BHFmQV-8mJ_2LU79tjkAJ5AeorsH%3De2PtLwk4g%40mail.gmail.com.

For more options, visit https://groups.google.com/d/optout.


Daniel Kuppitz <me@...>
 

Oops, Gmail didn't notify me about your response, sorry for the double-post.

On Fri, Sep 15, 2017 at 6:57 AM, Robert Dale <rob...@...> wrote:

g.V().hasLabel('player').as('player').V().hasLabel('Country').where(eq('player')).by('name').by('POB').addE('Z').from('player')

Robert Dale

On Fri, Sep 15, 2017 at 9:44 AM, Ankur Goel <ankur...@...> wrote:
Thnx Robert,

i am looking for a query like create edges where they have common properties without explicitly defining properties values:

g.V().has('player','POB',${A}).as('a').V().has('Country','name',{B}).addE('Z').from('a').where(${A} = ${B})

~AnkurG




On Friday, September 15, 2017 at 3:02:46 PM UTC+5:30, Ankur Goel wrote:
Hi,

 In JanusGraph to create edges we have two steps process:
  1. First identify the vertex
  2. Then create edges between vertex
Linkage between both steps is through App only.

How ever in neo4j, we can create edges using one step:

MATCH (a:player), (b:Country) WHERE a.POB = "X" AND b.name = "Y" 
CREATE (a)-[r: Z]->(b) 
RETURN a,b

Can we achieve the same in JanusGraph using Janus or tinkerpoop.

~AnkurG

--
You received this message because you are subscribed to the Google Groups "JanusGraph users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to janusgraph-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/janusgraph-users/06575748-b6cc-4f1a-aeac-cd76b9cb5b28%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "JanusGraph users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to janusgraph-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/janusgraph-users/CABed_4q6%3DB%2BNPgu-QgFETS1fjckAVF%3DbVCWMnaT7%3Dyq1o6eCpg%40mail.gmail.com.

For more options, visit https://groups.google.com/d/optout.


Daniel Kuppitz <me@...>
 

This should do the trick:

g.V().has('player').as('a').
  V().has('Country').where(eq('a')).by('name').by('POB').
    addE('Z').from('a')

However, note that this query will do 2 full table scans under the hood (unless Janus already has some runtime optimization that I'm not aware of). In any case it will be at least one full table scan.

Cheers,
Daniel


On Fri, Sep 15, 2017 at 6:44 AM, Ankur Goel <ankur...@...> wrote:
Thnx Robert,

i am looking for a query like create edges where they have common properties without explicitly defining properties values:

g.V().has('player','POB',${A}).as('a').V().has('Country','name',{B}).addE('Z').from('a').where(${A} = ${B})

~AnkurG




On Friday, September 15, 2017 at 3:02:46 PM UTC+5:30, Ankur Goel wrote:
Hi,

 In JanusGraph to create edges we have two steps process:
  1. First identify the vertex
  2. Then create edges between vertex
Linkage between both steps is through App only.

How ever in neo4j, we can create edges using one step:

MATCH (a:player), (b:Country) WHERE a.POB = "X" AND b.name = "Y" 
CREATE (a)-[r: Z]->(b) 
RETURN a,b

Can we achieve the same in JanusGraph using Janus or tinkerpoop.

~AnkurG

--
You received this message because you are subscribed to the Google Groups "JanusGraph users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to janusgraph-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/janusgraph-users/06575748-b6cc-4f1a-aeac-cd76b9cb5b28%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Robert Dale <rob...@...>
 


g.V().hasLabel('player').as('player').V().hasLabel('Country').where(eq('player')).by('name').by('POB').addE('Z').from('player')

Robert Dale

On Fri, Sep 15, 2017 at 9:44 AM, Ankur Goel <ankur...@...> wrote:
Thnx Robert,

i am looking for a query like create edges where they have common properties without explicitly defining properties values:

g.V().has('player','POB',${A}).as('a').V().has('Country','name',{B}).addE('Z').from('a').where(${A} = ${B})

~AnkurG




On Friday, September 15, 2017 at 3:02:46 PM UTC+5:30, Ankur Goel wrote:
Hi,

 In JanusGraph to create edges we have two steps process:
  1. First identify the vertex
  2. Then create edges between vertex
Linkage between both steps is through App only.

How ever in neo4j, we can create edges using one step:

MATCH (a:player), (b:Country) WHERE a.POB = "X" AND b.name = "Y" 
CREATE (a)-[r: Z]->(b) 
RETURN a,b

Can we achieve the same in JanusGraph using Janus or tinkerpoop.

~AnkurG

--
You received this message because you are subscribed to the Google Groups "JanusGraph users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to janusgraph-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/janusgraph-users/06575748-b6cc-4f1a-aeac-cd76b9cb5b28%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Ankur Goel <ankur...@...>
 

Thnx Robert,

i am looking for a query like create edges where they have common properties without explicitly defining properties values:

g.V().has('player','POB',${A}).as('a').V().has('Country','name',{B}).addE('Z').from('a').where(${A} = ${B})

~AnkurG




On Friday, September 15, 2017 at 3:02:46 PM UTC+5:30, Ankur Goel wrote:
Hi,

 In JanusGraph to create edges we have two steps process:
  1. First identify the vertex
  2. Then create edges between vertex
Linkage between both steps is through App only.

How ever in neo4j, we can create edges using one step:

MATCH (a:player), (b:Country) WHERE a.POB = "X" AND b.name = "Y" 
CREATE (a)-[r: Z]->(b) 
RETURN a,b

Can we achieve the same in JanusGraph using Janus or tinkerpoop.

~AnkurG


Robert Dale <rob...@...>
 

On Fri, Sep 15, 2017 at 6:56 AM, Robert Dale <rob...@...> wrote:

g.V().has('player','POB','X').as('a').V().has('Country','name','Y').addE('Z').from('a')

or you can flip it around

g.V().has('Country','name','Y').as('b').V().has('player','POB','X').addE('Z').to('b')


Robert Dale

On Fri, Sep 15, 2017 at 5:32 AM, Ankur Goel <ankur...@...> wrote:
Hi,

 In JanusGraph to create edges we have two steps process:
  1. First identify the vertex
  2. Then create edges between vertex
Linkage between both steps is through App only.

How ever in neo4j, we can create edges using one step:

MATCH (a:player), (b:Country) WHERE a.POB = "X" AND b.name = "Y" 
CREATE (a)-[r: Z]->(b) 
RETURN a,b

Can we achieve the same in JanusGraph using Janus or tinkerpoop.

~AnkurG

--
You received this message because you are subscribed to the Google Groups "JanusGraph users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to janusgraph-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/janusgraph-users/21e9d0a0-3747-49a5-8193-89f7dac51abe%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



Robert Dale <rob...@...>
 


g.V().has('player','POB','X').as('a').V().has('Country','name','Y').addE('Z').from('a')

or you can flip it around

g.V().has('Country','name','Y').as('b').V().has('player','POB','X').addE('Z').to('b')


Robert Dale

On Fri, Sep 15, 2017 at 5:32 AM, Ankur Goel <ankur...@...> wrote:
Hi,

 In JanusGraph to create edges we have two steps process:
  1. First identify the vertex
  2. Then create edges between vertex
Linkage between both steps is through App only.

How ever in neo4j, we can create edges using one step:

MATCH (a:player), (b:Country) WHERE a.POB = "X" AND b.name = "Y" 
CREATE (a)-[r: Z]->(b) 
RETURN a,b

Can we achieve the same in JanusGraph using Janus or tinkerpoop.

~AnkurG

--
You received this message because you are subscribed to the Google Groups "JanusGraph users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to janusgraph-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/janusgraph-users/21e9d0a0-3747-49a5-8193-89f7dac51abe%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Ankur Goel <ankur...@...>
 

Hi,

 In JanusGraph to create edges we have two steps process:
  1. First identify the vertex
  2. Then create edges between vertex
Linkage between both steps is through App only.

How ever in neo4j, we can create edges using one step:

MATCH (a:player), (b:Country) WHERE a.POB = "X" AND b.name = "Y" 
CREATE (a)-[r: Z]->(b) 
RETURN a,b

Can we achieve the same in JanusGraph using Janus or tinkerpoop.

~AnkurG