@JsonSerialize
@Document(collection = "fence")
@CompoundIndexes({
@CompoundIndex(name = "loc_groupId_idx",
def = "{ 'loc': 2dsphere, 'groups.groupId': 1 }",
unique = false) })
public class GeofenceMongoVO {
public GeofenceMongoVO() {}
@Id
private String fenceId;
@Field
private Long customerId;
@Field
private String fenceName;
@Field
private Byte type;
Run Code Online (Sandbox Code Playgroud)
这就是我试图确保地理空间字段和子文档(groupId)字段上的复合索引的方式。但不幸的是,这不起作用。有没有一种方法可以通过注释从java代码中确保2dsphere索引?