java - @Indexed on nested property not working in Spring-data for mongo -


i have following object structure:

@document(collection = "user") @typealias("user") public class user {     @id     private objectid id;     private contact info = new contact(); } 

and here contact pojo:

public class contact {     @indexed(unique = true)     private string mail; } 

but reasons not known me, don't see spring-data creating unique index property info.mail

to summarize, have json structure of user object: {_id:xxxxx,info:{mail:"abc@xyz.shoes"}}

and want create unique index on info.mail using spring data above pojo structure. please help.

as far remember, annotating embedded fields @indexed not work. @compoundindex way go:

@document(collection = "user") @typealias("user") @compoundindexes({     @compoundindex(name = "contact_email", def = "{ 'contact.mail': 1 }", unique = true) }) public class user {     @id     private objectid id;     private contact info = new contact(); } 

Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -