如何在 Java 中以编程方式使用 Spring Data 创建 MongoDB 复合索引?
使用 MongoTemplate 我可以创建这样的索引:
mongoTemplate.indexOps("collectionName").ensureIndex(new Index().on("fieldName", Sort.Direction.DESC)。
mongoTemplate.indexOps("collectionName").ensureIndex(new Index().on("fieldName", Sort.Direction.DESC)
有没有办法创建复合键?
我看到有一个类CompoundIndexDefinition,从它的名字来看,它似乎是这样做的,但我无法让它工作。
spring mongodb spring-data-mongodb
mongodb ×1
spring ×1
spring-data-mongodb ×1