未知运算符:$ search管道mongodb stitch

时间:2017-08-23 22:23:44

标签: mongodb mongodb-query pipeline

我试图通过新的MongoDB特征针脚使用文本操作符运行查询。我已经尝试了一些选项,但是呼叫响应以下消息:

  

未知运算符:$ 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"
        }
    }
}])

2 个答案:

答案 0 :(得分:1)

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

答案 1 :(得分:0)

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

相关问题