I am trying to run a query using text operator by the new MongoDB feature stitch. I have already tried a few options, but the call responds with the following message:
unknown operator: $search
How can I resolve this error?
I also have the text index created.
{
"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
}
Attempt #1:
client.executePipeline([{
"service": "mongodb-atlas",
"action": "aggregate",
"args": {
"database": "test",
"collection": "scripts",
"pipeline": [{
$match: {
$text: {
$search: "docker"
}
}
}
]
}
}])
Attempt #2:
db.collection('scripts').find({"$text":{"$search":'docker'}})
Attempt #3:
db.collection('scripts').aggregate([{
"$match": {
"$text": {
"$search": "docker"
}
}
}])
UPDATE:
I applied this work around.
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();
});
Full-text search in Stitch pipeline aggregate actions is currently unsupported in the Beta version of the Stitch product but we hope to support them when Stitch reaches GA (General Availability).