I am using Spring Boot 2.0.0.M3. And I have the following object structure:
@Document(collections="note")
public class Note {
String id;
@Indexed(background=true,unique=true)
String requestid;
}
@Document(collection="noteExpression")
public class NoteExpression {
public static class Error {
private DateTime dateTime = DateTime.now();
private Note note;
private String exception;
}
String id;
//Some other fields
Error error;
}
In the object of NoteExpression, I need to store the error information when something unexpected occurs. Everything seems to be fine. But the problem is Mongo will create a unique index for the nested property Note in NoteExpression.Error.
See the result of the Mongo command below:
>db.noteExpression.getIndexes()
[
{
"v" : 2,
"key" : {
"_id" : 1
},
"name" : "_id_",
"ns" : "test.noteExpression"
},
{
"v" : 2,
"unique" : true,
"key" : {
"errors.note.requestid" : 1
},
"name" : "errors.note.requestid",
"ns" : "test.noteExpression",
"background" : true
}
]
Unique index for requestid on the documents of Note is necessary in my system, but I don't want the unique index on the documents of NoteExpression. Is there any way to avoid creating the index on NoteExpression?