基于spring-data-mongodb使用@indexed的项目在使用多租户集合时不起作用。以下是代码:
@Document(collection = "#{ @tenantProvider.getTenant()}activity")
@Data
public class Activity {
@Id
private String id;
@Indexed
private String activityId;
}
答案 0 :(得分:1)
如果集合定义是动态的,您当然必须确保手动创建索引,因为我们无法确定可能受影响的所有可能集合。
用户通常会使用IndexOperations
手动创建这些索引。