5 javascript mongoose mongodb node.js
使用 Mongo DB 的$text功能,我们可以创建可搜索的索引,我在 Mongoose 中通过应用通过。架构,例如:
RandomSchema.index({ description: 'text', notice: 'text'});
Run Code Online (Sandbox Code Playgroud)
一个物体类似于
{
description: "first",
notice: "next"
..
}
Run Code Online (Sandbox Code Playgroud)
这工作正常 - 但我怎样才能让它适用于嵌套文本值?
以下任何一项都不起作用:
RandomSchema.index({ "randObj.title": 'text'});
RandomSchema.index({ randObj: { title: 'text' }});
Run Code Online (Sandbox Code Playgroud)
一个例子可能在哪里
{
randObj: {
title: "random string"
..
}
..
}
Run Code Online (Sandbox Code Playgroud)
此外,如果文档使用填充字段,我们是否也能够索引这些字符串字段?