Showing results for 
Search instead for 
Did you mean: 

Head's Up! Site maintenance this Wednesday, February 1. Disruptions expected as we migrate the forums.

I want to know how to eliminate duplicate nodes in neo4j using spring boot without using merge clause

Node Link

I have created a pojo class and set up a structure how nodes should be created in neo4j. Using .save method which is inbuilt in neo4jRepository i am sending data using postman.
public Book addBook(Book book) {
public Classifier addingClassifier(@RequestBody Book book)) {
return bookService.addBook(book);

if i send same data using postman then neo4j is creating duplicate nodes. How to stop creating duplicate nodes.


use a unique constraint.

tried with unique constraint but it is of no use. It did not stop creating duplicate nodes.

By definition a unique constraint prevents duplication. I guess you're applying it not correctly.

Node Link

No, I think I am using it correctly.

public class Book {

private Long id;

@Index(unique = true)
private String name;

@Index(unique = true)
@Relationship(type = "Comprises_Of",direction = Relationship.OUTGOING)
private Set<Publishers> publishers;


what constraints do you actually have in the db: call db.constraints() ?


no constraints are applied to the fields.

@Index(Unique = true) is not working in the expected way. Please verify how to apply the unique constraint in spring boot code and let me know.

why not just fire a create constraint on .... statement directly to the database and you're done?