我试图通过新的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"
}
}
}
]
}
}])第二次尝试:
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();
});发布于 2017-08-25 19:48:25
Stitch管道聚合操作中的全文搜索目前在Beta版本的Stitch产品中是不受支持的,但是我们希望在Stitch达到GA (通用可用性)时支持它们。
发布于 2019-10-02 10:48:30
两年后,情况仍然不变,$text在Stitch中不受支持:
https://mongodb.canny.io/mongodb-stitch/p/full-text-search
您是如何实现文本搜索的?现在,MongoDB地图集有文本搜索功能,但只能在M30集群或更大的集群上使用:
https://stackoverflow.com/questions/45850169
复制相似问题