This statement is idempotent, but also updates properties on nodes / rels
HTH Michael
LOAD CSV FROM "url" as row
// get-or-create-node
MERGE (n1:Node1 {row.id1})
// update prop
SET n1.prop1 = row.prop1
// get-or-create-node
MERGE (n2:Node2 {row.id2})
// update prop
SET n2.prop2 = row.prop2
// get-or-create-relationship
MERGE (n1)-[rel:REL]->(n2)
SET rel.prop = row.relProp
On Mon, Aug 21, 2017 at 2:52 PM, Koen Kleingeld <[email protected]>
wrote:
> Hi andy, i am already using the merge command which works fine to create
> unique records but i also want to be able to for example update / change an
> attribute on an existing node .. i maybe have to do some more testing with
> all merge options ..
>
> koen
>
> 2017-08-21 10:12 GMT+02:00 LAW Andy <[email protected]>:
>
>> Koen,
>>
>> I think that you are looking for the MERGE command.
>>
>> http://neo4j.com/docs/developer-manual/current/cypher/clauses/merge/
>>
>> Later,
>>
>> Andy
>>
>>
>> > On 21 Aug 2017, at 05:32, koen <[email protected]> wrote:
>> >
>> > In addition.. so if i would run a LOAD CSV twice in a row with
>> exactly the same file i would like nothing to happen to the nodes / rels
>> (meaning no creation of duplicate rels etc).. If i would run the import
>> with almost the same csv file (with only one property changed somewhere in
>> the file ) only that specific property would be updated in that specific
>> node and nothing would change to the other rels / nodes .. so what are the
>> cypher statements that make this happen ..
>> >
>> > Thanks Koen
>> >
>> >
>> >
>> > Op maandag 21 augustus 2017 06:22:12 UTC+2 schreef koen:
>> > Hi, a generic question. Lets assume you import data from a CSV file
>> into neo4j using cypher "LOAD CSV".
>> > The first/initial run will give you a full load of all nodes /
>> properties Lets assume this results in several node types each of them with
>> several properties and several relationships..
>> >
>> > Now i have a new CSV file of the same format as the initial load one.
>> In this file some new records might have been added and for existing
>> records (nodes or rels) the properties might have been changed.
>> >
>> > My question .. what would be the best approach to process such "delta"
>> import ..
>> >
>> > 1) resolve the differences during pre-processing and generate a delte
>> import file ..
>> > OR
>> > 2) is there a clever way to write cypher code to import initial loads
>> (which is the straightforward part) and also verify at the same time if
>> existing nodes need to be updated when doing a delta import
>> >
>> > thanks
>> >
>> > Koen
>> >
>> >
>> >
>> >
>> >
>> >
>> > --
>> > 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 [email protected].
>> > For more options, visit https://groups.google.com/d/optout.
>>
>>
>> --
>> The University of Edinburgh is a charitable body, registered in
>> Scotland, with registration number SC005336.
>>
>> --
>> You received this message because you are subscribed to a topic in the
>> Google Groups "Neo4j" group.
>> To unsubscribe from this topic, visit https://groups.google.com/d/to
>> pic/neo4j/hTjPHgqcy1Y/unsubscribe.
>> To unsubscribe from this group and all its topics, send an email to
>> [email protected].
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
>
> --
>
> Groeten / Best Regards,
>
> Koen
>
> --
> 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 [email protected].
> 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 [email protected].
For more options, visit https://groups.google.com/d/optout.