I'm trying to index fields on an embedded collection and the indexes don't seem to be created. For example:
I want to index the Credential.provider and Credential.providerUid. If I put the annotation on the Credential class, then a Credential collection is made with the proper index. However, that doesn't get me anywhere.
Is there something I'm doing wrong, or do I need to do this by hand via the MongoTemplate?
Thanks.
Code:
@Document
@CompoundIndexes({
@CompoundIndex(name = "cred_idx", def = "{ 'credentials.provider': 1, 'credentials.providerUid': 1 }")
})
public class User {
@Id
private ObjectId id;
@Field
private String name;
@Field
private Set<Credential> credentials = new HashSet<Credential>();
}
public class Credential {
private String provider;
private String providerUid;
}
Is there something I'm doing wrong, or do I need to do this by hand via the MongoTemplate?
Thanks.