例如,我有以下文档结构:
{
"subject":"Joe owns a dog",
"content":"Dogs are man's best friend",
"likes": 60,
"year":2015,
"language":"english"
}
Run Code Online (Sandbox Code Playgroud)
架构将是:
var schema = new Schema({
subject: {type: String},
content: {type: String},
likes: {type: int},
year: {type: int},
language: {type: String}
}
schema.createIndex({"subject": "text"});
Run Code Online (Sandbox Code Playgroud)
我可以动态删除索引并创建另一个包含更多字段的索引吗?
因此,如果现在它在主题字段中搜索关键字,我想动态地更改它并搜索"主题"和"内容".改为:
schema.createIndex({"subject": "text", "content": "text"});
Run Code Online (Sandbox Code Playgroud)
你觉得这可能吗?
非常感谢.