3.7. Creating unique nodes

In many use cases, a certain level of uniqueness is desired among entities. You could for instance, imagine that only one user with a certain e-mail address may exist in a system. If multiple concurrent threads naively try to create the user, duplicates will be created. There are three main strategies for ensuring uniqueness, and they all work across cluster and single-instance deployments.

3.7.1. Single thread

By using a single thread, no two threads will even try to create a particular entity simultaneously. On cluster an external single-threaded client can perform the operations.

3.7.2. Get or create

Defining a uniqueness constraint and using the Cypher MERGE clause is the most efficient way to get or create a unique node. See Section 2.9, “Getting or creating a unique node using Cypher and uniqueness constraints” for more information.