Spring boot / mongo wont create index with the index annotation
use auto-index-creation: true
in your application properties.Add billow line in your application.properties
spring.data.mongodb.auto-index-creation: true
I found the problem. I had another collection also with a url field marked as unqiue. I had to specify the name of the index on one of them otherwise it seems that it considered that the index already exists even though it was on two different collections
@Indexed(name = "meta_url_index_unique", unique = true)
private String url;
Edit: This answer was before the author updates his question
I believe you need to use the @Document annotation on top the class declaration
So your class should be
@Document
public class LinkMetaData {
@Indexed(unique = true)
private String url;
...
}