未知运算符:$search pipeline mongodb stitch

unknown operator: $search pipeline mongodb stitch

我正在尝试 运行 通过新的 MongoDB 功能拼接使用文本运算符进行查询。我已经尝试了几个选项,但呼叫响应以下消息:

unknown operator: $search

我该如何解决这个错误?

我也创建了文本索引。

{
    "v" : 2,
    "key" : {
        "_fts" : "text",
        "_ftsx" : 1
    },
    "name" : "script_text_description_text",
    "ns" : "test.scripts",
    "weights" : {
        "description" : 1,
        "script" : 1
    },
    "default_language" : "english",
    "language_override" : "language",
    "textIndexVersion" : 3
}

尝试 #1:

client.executePipeline([{
    "service": "mongodb-atlas",
    "action": "aggregate",
    "args": {
        "database": "test",
        "collection": "scripts",
        "pipeline": [{
                $match: {
                    $text: {
                        $search: "docker"
                    }
                }
            }
        ]
    }
}])

尝试 #2:

db.collection('scripts').find({"$text":{"$search":'docker'}})

尝试 #3:

db.collection('scripts').aggregate([{
    "$match": {
        "$text": {
            "$search": "docker"
        }
    }
}])

更新:

我应用了这个变通方法。

import { StitchClientFactory,BSON } from 'mongodb-stitch';

let bsonRegex = new BSON.BSONRegExp(search, 'i')
        // showLoading();
        db.collection('clients').find({owner_id: client.authedId(),name:bsonRegex}).execute().then(docs => {
            funct(docs);
            // hideLoading();
        });

Stitch 产品的 Beta 版目前不支持 Stitch 管道聚合操作中的全文搜索,但我们希望在 Stitch 达到 GA(全面可用性)时支持它们。

2年后,情况依旧,$text Stitch不支持:

https://mongodb.canny.io/mongodb-stitch/p/full-text-search

您是如何实现文本搜索的?现在 MongoDB Atlas 具有文本搜索功能,但仅适用于 M30 及更大的集群:

https://docs.atlas.mongodb.com/full-text-search/?jmp=docs