Re: [Neo4j] how to add new property to an existing relationship?

2017-01-02 Thread Bikash Karmokar
thanks a lot. 

On Wednesday, March 23, 2016 at 8:53:31 AM UTC+1, Michael Hunger wrote:
>
> MATCH (p:Product)-[r:inside]->(c:Category) 
>
> SET r.type = p.id + '->' + c.id
>
> But I *strongly recommend against* setting this kind of property !!
>
> As you can always compute the information!
>
> MATCH (p:Product)-[r:inside]->(c:Category) 
>
> RETURN p.id + '->' + c.id
>
>
> MERGE always tries to find the WHOLE pattern and if it can't find it will 
> CREATE it.
>
> Am 23.03.2016 um 08:36 schrieb kincheong lau  >:
>
> for each existing 'product' that 'inside' a 'category', I would like to 
> add a property in relationship 'product->category'. When I run below 
> cypher, it create a new relationship instead of adding new property in the 
> existing one...how can I make it 1 relationship only?
>
>
> 1) Existing relationship before change
>
> (p:Product)-[r:inside]->(c.Category)
>
> there is no property in [ r ]
>
> 2) Cypher to run
>
> MATCH (p:Product), (c:Category) 
> MERGE (p)-[r:inside {type: p.id + '->' + c.id }]->(c)
>
> 3) it creates new relationship and the existing no change
>
> (p:Product)-[r:inside {type: p.id->c.id }]->(c:Category)
>
> (p:Product)-[r:inside]->(c:Category)
>
>
>
>
>
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Neo4j" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to neo4j+un...@googlegroups.com .
> For more options, visit https://groups.google.com/d/optout.
>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Neo4j" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to neo4j+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Neo4j] how to add new property to an existing relationship?

2016-03-23 Thread Michael Hunger
No, there are no constraints on rels.

What's your use-case? Do you have an actual performance problem?

Michael

> Am 23.03.2016 um 09:49 schrieb kincheong lau :
> 
> Thanks!  I was thinking adding unique property and then create 
> index/constraint might improve performance, would that be the case?
> 
> 
> On Wednesday, March 23, 2016 at 3:53:31 PM UTC+8, Michael Hunger wrote:
>> MATCH (p:Product)-[r:inside]->(c:Category) 
> SET r.type = p.id  + '->' + c.id 
> 
> But I strongly recommend against setting this kind of property !!
> 
> As you can always compute the information!
> 
>> MATCH (p:Product)-[r:inside]->(c:Category) 
> RETURN p.id  + '->' + c.id 
> 
> 
> MERGE always tries to find the WHOLE pattern and if it can't find it will 
> CREATE it.
> 
>> Am 23.03.2016 um 08:36 schrieb kincheong lau gmail.com 
>> >:
>> 
>> for each existing 'product' that 'inside' a 'category', I would like to add 
>> a property in relationship 'product->category'. When I run below cypher, it 
>> create a new relationship instead of adding new property in the existing 
>> one...how can I make it 1 relationship only?
>> 
>> 
>> 1) Existing relationship before change
>> 
>> (p:Product)-[r:inside]->(c.Category)
>> 
>> there is no property in [ r ]
>> 
>> 2) Cypher to run
>> 
>> MATCH (p:Product), (c:Category) 
>> MERGE (p)-[r:inside {type: p.id  + '->' + c.id  
>> }]->(c)
>> 
>> 3) it creates new relationship and the existing no change
>> 
>> (p:Product)-[r:inside {type: p.id->c.id  }]->(c:Category)
>> 
>> (p:Product)-[r:inside]->(c:Category)
>> 
>> 
>> 
>> 
>> 
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "Neo4j" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to neo4j+un...@ <>googlegroups.com .
>> For more options, visit https://groups.google.com/d/optout 
>> .
> 
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Neo4j" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to neo4j+unsubscr...@googlegroups.com 
> .
> For more options, visit https://groups.google.com/d/optout 
> .

-- 
You received this message because you are subscribed to the Google Groups 
"Neo4j" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to neo4j+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Neo4j] how to add new property to an existing relationship?

2016-03-23 Thread kincheong lau
Thanks!  I was thinking adding unique property and then create 
index/constraint might improve performance, would that be the case?


On Wednesday, March 23, 2016 at 3:53:31 PM UTC+8, Michael Hunger wrote:
>
> MATCH (p:Product)-[r:inside]->(c:Category) 
>
> SET r.type = p.id + '->' + c.id
>
> But I *strongly recommend against* setting this kind of property !!
>
> As you can always compute the information!
>
> MATCH (p:Product)-[r:inside]->(c:Category) 
>
> RETURN p.id + '->' + c.id
>
>
> MERGE always tries to find the WHOLE pattern and if it can't find it will 
> CREATE it.
>
> Am 23.03.2016 um 08:36 schrieb kincheong lau  >:
>
> for each existing 'product' that 'inside' a 'category', I would like to 
> add a property in relationship 'product->category'. When I run below 
> cypher, it create a new relationship instead of adding new property in the 
> existing one...how can I make it 1 relationship only?
>
>
> 1) Existing relationship before change
>
> (p:Product)-[r:inside]->(c.Category)
>
> there is no property in [ r ]
>
> 2) Cypher to run
>
> MATCH (p:Product), (c:Category) 
> MERGE (p)-[r:inside {type: p.id + '->' + c.id }]->(c)
>
> 3) it creates new relationship and the existing no change
>
> (p:Product)-[r:inside {type: p.id->c.id }]->(c:Category)
>
> (p:Product)-[r:inside]->(c:Category)
>
>
>
>
>
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Neo4j" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to neo4j+un...@googlegroups.com .
> For more options, visit https://groups.google.com/d/optout.
>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Neo4j" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to neo4j+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Neo4j] how to add new property to an existing relationship?

2016-03-23 Thread Michael Hunger
> MATCH (p:Product)-[r:inside]->(c:Category) 
SET r.type = p.id + '->' + c.id

But I strongly recommend against setting this kind of property !!

As you can always compute the information!

> MATCH (p:Product)-[r:inside]->(c:Category) 
RETURN p.id + '->' + c.id


MERGE always tries to find the WHOLE pattern and if it can't find it will 
CREATE it.

> Am 23.03.2016 um 08:36 schrieb kincheong lau :
> 
> for each existing 'product' that 'inside' a 'category', I would like to add a 
> property in relationship 'product->category'. When I run below cypher, it 
> create a new relationship instead of adding new property in the existing 
> one...how can I make it 1 relationship only?
> 
> 
> 1) Existing relationship before change
> 
> (p:Product)-[r:inside]->(c.Category)
> 
> there is no property in [ r ]
> 
> 2) Cypher to run
> 
> MATCH (p:Product), (c:Category)
> MERGE (p)-[r:inside {type: p.id + '->' + c.id }]->(c)
> 
> 3) it creates new relationship and the existing no change
> 
> (p:Product)-[r:inside {type: p.id->c.id }]->(c:Category)
> 
> (p:Product)-[r:inside]->(c:Category)
> 
> 
> 
> 
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Neo4j" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to neo4j+unsubscr...@googlegroups.com 
> .
> For more options, visit https://groups.google.com/d/optout 
> .

-- 
You received this message because you are subscribed to the Google Groups 
"Neo4j" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to neo4j+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.