Skip to content

Conversation

@lidiazuin
Copy link
Contributor

No description provided.

Copy link
Contributor

@AlexicaWright AlexicaWright left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice rework!

====
== Delete properties

Neo4j doesn't store null values, which means that if you set a property value as `null`, it will be automatically removed from your graph.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Neo4j doesn't store null values, which means that if you set a property value as `null`, it will be automatically removed from your graph.
To remove a property, either use the `REMOVE` clause, or set its value to `null`.
Neo4j doesn't store properties without values, so doing so removes the property from a node.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But even when you use REMOVE and then you MATCH it, you'll get null as value too. The sentence like that makes me understand that there's an option to literally remove the property, but it doesn't work like that

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But this is explained a few lines further down, that the result of both operations is "Set 1 property".


== Conclusion

In this tutorial, you have seen how to update the information in your graph and avoid issues such as duplication or lack of information about when the changes were made.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
In this tutorial, you have seen how to update the information in your graph and avoid issues such as duplication or lack of information about when the changes were made.
In this tutorial, you have seen how to update nodes, relationships, and properties.
You have also seen how to delete data from the graph as well as how to avoid duplication when adding new data.

Lacking information about when changes were made is not really an issue in most graphs, is it?

|===
| m | r | j

| (:Person {twitter: "@mark", name: "Mark"})
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Again, the twitter property was never added back after Mark's node was deleted.

Earlier you learned how to represent nodes, relationships, labels, properties, and patterns in Cypher.
This section adds another level to your knowledge by introducing how to update and delete data with Cypher.
This tutorial shows how to update information in the graph by changing, removing, and adding nodes, relationships, and properties.
It also addresses how to avoid duplication and how to keep track of changes by adding new properties to the graph.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure the main purpose of using merge action clauses is to track change, so maybe consider changing the end of this sentence? I left a comment in the relevant section as well.

Copy link
Contributor

@AlexicaWright AlexicaWright left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great update! A few more comments. I recommend to run the example queries. You can run them in Desktop, easy peasy and you don't need to set up an Aura account. Let me know if you have any questions!


Notice that here `MATCH` is used to find both Mark's node and Jennifer's node before we use `MERGE` to find or create the relationship between them.
Cypher can't find this pattern since Mark's node and all its relationships were deleted, and only their node was recreated.
Consequently, if you use `CREATE` instead of `MERGE`, the whole pattern is created (with both nodes and the relationship), which results in duplicate nodes for `Jennifer` and `Mark`, but a new relationship.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MERGE recreates the whole pattern, regardless of whether any of the nodes existed already or not. So if you run this using CREATE instead, you still get the same result: two Mark nodes and one Jennifer node.
The point to make here is that you need to MATCH the nodes first and then use MERGE to recreate the relationship.

Copy link
Contributor

@AlexicaWright AlexicaWright left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not getting the same results when I run the queries. I can create duplicates and no errors are thrown.

To start, let us look at an example of this by adding Mark back to our database using the query below.
You can use `MERGE` to ensure that Cypher checks the database for an existing node for Mark.
Since you removed Mark's node in the previous examples, Cypher will not find an existing match and will create the node new with the `name` property set to 'Mark'.
You won't get any results.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes you do, both queries yield the same results: Created 2 nodes, created 1 relationship, set 2 properties, added 2 labels. Duplicate Person nodes created and a new relationship between them added.

----
--
CREATE (mark:Person {name: 'Mark'})
CREATE (jennifer:Person {name: 'Jennifer'})
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You used Ann in the two examples above?

Copy link
Contributor

@AlexicaWright AlexicaWright left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Getting there! A few more comments, sorry ;)


1+d|Rows: 1
|===

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You had a great explanation of the difference between CREATE and MERGE before. I think you should keep that and place it here. It could be useful with a little summary of when to use which and why.

Comment on lines 301 to 302
If you run the same statement again, using `CREATE`, you will create another duplication.
But if you use `MERGE`, Cypher only finds the now existing node.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
If you run the same statement again, using `CREATE`, you will create another duplication.
But if you use `MERGE`, Cypher only finds the now existing node.

This has already been covered above.

====

=== Handling _MERGE_ criteria
`MATCH` finds both Mark and Ann's node before `MERGE` (finds or) creates the relationship between them.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can use CREATE here, it doesn't matter as long as there is no relationship already. What matters is that you MATCH Ann and Mark first and then use their variables in the MERGE clause. That's what avoids the duplication. I think we need to be clear about that.

--

*Query result:*
Cypher returns the existing node without creating a new one:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe there should be an example adding Jennifer back using merge to show what MERGE does? You had an explanation in there before, but if you don't want to put that back, I think we need to showcase that MERGE looks for the node/pattern and if it doesn't exist, creates it.
So using MERGE with Ann's node shows that there was a match so no creation of a new node, and using MERGE with Jennifer's node could show that when there is no match (since we deleted her in the previous example), a node is created. WDYT?

Copy link
Contributor

@AlexicaWright AlexicaWright left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just one last comment. Promise! It looks really good!

Copy link
Contributor

@AlexicaWright AlexicaWright left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

APPROVE!!!

@neo4j-docops-agent
Copy link
Collaborator

neo4j-docops-agent commented Dec 4, 2025

Thanks for the documentation updates.

The preview documentation has now been torn down - reopening this PR will republish it.

@lidiazuin lidiazuin merged commit 252db14 into neo4j:dev Dec 4, 2025
5 checks passed
@lidiazuin lidiazuin deleted the cypherupdate branch December 4, 2025 12:30
lidiazuin added a commit to lidiazuin/docs-getting-started that referenced this pull request Dec 4, 2025
* Turning the page into a tutorial

* Apply suggestions from code review

Co-authored-by: Jessica Wright <[email protected]>

* updates after review

* Apply suggestions from code review

Co-authored-by: Jessica Wright <[email protected]>

* updates after review and testing

* Apply suggestions from code review

Co-authored-by: Jessica Wright <[email protected]>

* updates after review

* Apply suggestions from code review

Co-authored-by: Jessica Wright <[email protected]>

* fixes after review

* Apply suggestions from code review

Co-authored-by: Jessica Wright <[email protected]>

* update after review

* Update modules/ROOT/pages/cypher/updating.adoc

Co-authored-by: Jessica Wright <[email protected]>

---------

Co-authored-by: Jessica Wright <[email protected]>
lidiazuin added a commit that referenced this pull request Dec 4, 2025
* Turning the page into a tutorial

* Apply suggestions from code review



* updates after review

* Apply suggestions from code review



* updates after review and testing

* Apply suggestions from code review



* updates after review

* Apply suggestions from code review



* fixes after review

* Apply suggestions from code review



* update after review

* Update modules/ROOT/pages/cypher/updating.adoc



---------

Co-authored-by: Jessica Wright <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants