0
我想通過新的MongoDB功能針腳使用文本運算符查詢。我已經嘗試了幾個選項,但是呼叫以下消息響應:
未知運營商:$搜索
我怎樣才能解決這個問題?
我也創建了文本索引。
{
"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"
}
}
}])
集合中文檔的模式是什麼?你想實現什麼? – pedromss