【发布时间】:2022-10-14 04:05:44
【问题描述】:
如何使用昵称作为索引查找文档?我不知道它是大写还是小写。
_id: ...
credits: {
nickname: "test"
password: "hash"
}
现在我正在尝试做这样的事情,但没有成功。
mongo.createIndex(new Document("credits.nickname", "text"),
new IndexOptions().name("nickname").unique(true)
.collation(Collation.builder()
.locale("simple").caseLevel(false).collationStrength(CollationStrength.PRIMARY)
.build()))
// null
mongo.collection().find(new Document("credits.nickname", "TEST")).projection(Projections.include("credits"))
【问题讨论】:
标签: java mongodb mongodb-query