【发布时间】:2017-04-07 10:42:57
【问题描述】:
例如,我有以下文档结构:
{
"subject":"Joe owns a dog",
"content":"Dogs are man's best friend",
"likes": 60,
"year":2015,
"language":"english"
}
架构将是:
var schema = new Schema({
subject: {type: String},
content: {type: String},
likes: {type: int},
year: {type: int},
language: {type: String}
}
schema.createIndex({"subject": "text"});
我可以动态删除索引并创建另一个具有更多字段的索引吗?
因此,如果现在它在主题字段中搜索关键字,我想动态更改它并在“主题”和“内容”中搜索。改为:
schema.createIndex({"subject": "text", "content": "text"});
你认为这可能吗?
非常感谢。
【问题讨论】:
标签: node.js mongodb mongoose mongodb-query