mongodb 文本索引
 发布于 8 年前  作者 JustforNode  3713 次预览  最后一次回复是 8 年前  来自 问答 

const FeedbackSchema = new Schema({ content: String, user: { mobile: String, real_name: String, description: String, } }) 例如有个这样的schema,user字段是一个对象,如何给user字段的description添加文本索引?

4 回复
JustforNode

会了,FeedbackSchema.index({ ‘user. description’: ‘text’ });

beyond5959
const FeedbackSchema = new Schema({
content: String,
user: {
mobile: String,
real_name: String,
description: {
	type: String,
	index: true,
},
}
})

这样?

JustforNode

@beyond5959 这样加的貌似不是文本索引,是单键索引