草庐IT

CompoundIndex

全部标签

mongodb - 如何将 spring data mongo @CompoundIndex 与子集合一起使用?

假设我有如下实体:@Document(collection="doc_a")publicclassA{@Field("id")privateIntegerid;@Field("b")privateCollectionb;...}publicclassB{@Field("id")privateIntegerid;...}是否可以同时使用关于A.id和B.id的复合索引?我的意思可能是这样的:@CompoundIndex(name="aid_bid_idx",def="{'id','b.id'}")提前致谢。 最佳答案 我已经在我的应用

mongodb - 如何将 spring data mongo @CompoundIndex 与子集合一起使用?

假设我有如下实体:@Document(collection="doc_a")publicclassA{@Field("id")privateIntegerid;@Field("b")privateCollectionb;...}publicclassB{@Field("id")privateIntegerid;...}是否可以同时使用关于A.id和B.id的复合索引?我的意思可能是这样的:@CompoundIndex(name="aid_bid_idx",def="{'id','b.id'}")提前致谢。 最佳答案 我已经在我的应用

java - @CompoundIndex 在 Spring Data MongoDB 中不起作用

我正在使用SpringDataMongoDB开发一个应用程序。我想在我的一个模型上创建一个复合索引。我在顶部添加了一个@CompoundIndex注释,如下所示:@Document@CompoundIndexes({@CompoundIndex(name="name_",def="{'tenantId':1,'name':1}",unique=true)})publicclassMyModel{}但是,没有创建索引。我还尝试将@CompoundIndex直接放在类上方。该集合仍然缺少索引。像这样创建时,相同的索引定义可以正常工作:mongoTemplate.indexOps(MyMod