Thanks Much Chris
Yes, It is working fine for me.
One problem i am facing with indexing field for TTL from Java which we are using Spring Data Mongodb Framework.
In that below case for nested object spring data mongodb creating multiple TTL index for Class(ClassA). So finally multiple TTL index there in mongodb.
- What will happen when there is multiple TTL index for different field for the same collection.
- How to annotate this ttl index from actual class (ClassA) by having the variable in abstract?.
Note : Compound index i am doing from actual class (Class A), that will not affect even having this class instance in other db class.
Nested Object by extending abstract:
@Document
@CompoundIndexes({
@CompoundIndex(name = “var1_IX”, def = “{‘classBVar.var1’: 1}”),
}
public class ClassA extends MyDBObjectAbstract {
private ClassB classBVar = new ClassB() ;
}
Noraml Object by extending abstract :
@Document
@CompoundIndexes({
@CompoundIndex(name = “var1_InnerIX”, def = “{‘var1’: 1}”),
}
public class ClassB extends MyDBObjectAbstract {
private String var1 =“Welcome”
}
Abstract class with TTL Index Annotation :
public abstract class FMObjectAbstract {
@Indexed(name = “expireRecordAt_index”, expireAfterSeconds = 0)
private Date expireRecordAt=null;
}
Multiple Index created for Class A for TTL:
{
“v” : 2,
“key” : {
“classBVar.expireRecordAt” : 1
},
“name” : “classBVar.expireRecordAt_index”,
“ns” : “MYDB.ClassA”,
“expireAfterSeconds” : NumberLong(0)
},
{
“v” : 2,
“key” : {
“expireRecordAt” : 1
},
“name” : “expireRecordAt_index”,
“ns” : “MYDB.ClassA”,
“expireAfterSeconds” : NumberLong(0)
}