I am trying to create unique index for my collection in java class using @Indexed annotation in spring-boot. When I use @Indexed on a field in pojo of collection's document:
@Indexed(unique = true)
private String name;
Where name field contains string consisting of English alphabet and I want to stop duplicate entry of name field. Field name is not working as unique and I am able to add documents having duplicate name field. To make it work I have to make id field unique=false:
@Indexed(unique = false)
String id;
Is this correct approach, can we make id field unique=false and make some other field unique=true to make that field unique.
@Indexedwithout specifying unique true or false. - pvpkiran