Spring MongoDB 复合索引覆盖

时间:2021-07-02 22:45:11

标签: mongodb spring-boot indexing mongodb-indexes

我有一个包含字段 enginetypemanufacturerId 的文档。我在 3 个字段上创建了一个复合 unique 索引,因此我使用以下内容来创建索引。

@CompoundIndex(name = "engine_type_manufacturerId", def = "{'engine' : 1, 'type' : 1, 'manufacturerId': 1}", unique = true)

这样做可以避免 3 个字段的组合出现重复条目​​。

继续,在我的应用程序中,我有一些查询,我将只按 engineengine & type 搜索。现在,我的问题是,我之前创建的复合唯一索引是否会涵盖 engineengine & type 上的查询的情况,还是应该为这些查询创建新索引?

0 个答案:

没有答案
相关问题