通配符文本索引和继承模式

Wildcard Text Index and inherited schemas

我有 1 个根模式和 4 个使用 discriminatorKey 的继承模式 http://mongoosejs.com/docs/discriminators.html

在这种情况下,我不清楚是否可以使用通配符文本索引。目的是独立索引每个继承模式的所有字符串字段。 https://docs.mongodb.org/manual/core/index-text/

编辑 在我的猫鼬根架构上添加此 myRootSchema.index({ "_type": 1, "$**": "text" }); 我在尝试查询时收到此错误。我是否也应该在继承的模式上重复这个?

{
"name": "MongoError",
"message": "error processing query: ns=MYDB.caseNotesTree: TEXT : query=title, language=english, caseSensitive=0, diacriticSensitive=0, tag=NULL\nSort: {}\nProj: {}\n planner returned error: failed to use text index to satisfy $text query (if text index is compound, are equality predicates given for all prefix fields?)",
"waitedMS": 0,
"ok": 0,
"errmsg": "error processing query: ns=MYDB.caseNotesTree: TEXT : query=title, language=english, caseSensitive=0, diacriticSensitive=0, tag=NULL\nSort: {}\nProj: {}\n planner returned error: failed to use text index to satisfy $text query (if text index is compound, are equality predicates given for all prefix fields?)",
"code": 2
}

查询:

Model
    .find(
        { $text : { $search :req.query.q } }

    )
    .exec(function(err, data) {
        if(err)res.json(err)
        res.json(data)
    });

使用 kind 鉴别器字段作为索引中的前导字段来有效地利用 wildcard index with inherited schemas, you'd want to use a compound text index

{ kind: 1, "$**": "text" }