Search code examples
mongodbaws-documentdb

"Feature not supported: $text" in document db with mongodb 3.6 compatiability


Hi I am using AWS documentDB with mongodb 3.6 compatiability but getting mentioned error in the function below. I am not sure how to get around this.

Index creation

ScenarioSchema.index({
"friendlyId": "text",
"steps.text": "text",
"title": "text"
}, { name: "scenarioTextIndex" });


var createSearchFilter = function (searchOptions)
 {
    var searchTerm = searchOptions.searchText || '';
    if (searchOptions.searchCondition.toUpperCase() === 'AND') {
        searchTerm = searchTerm.split(" ").join('" "');
    }
    if (searchOptions.excludeSearchText) {
        var excludeSearchText = searchOptions.excludeSearchText.split(" ").join(' -');
        searchTerm = searchTerm.concat(" -" + excludeSearchText);
    }
    var allowedPhases = getRoleBasedPhases(searchOptions.userRoles, searchOptions.phases);
    return {$text: {$search: searchTerm}, 'phase.code': {$in: allowedPhases}};
};

I am getting code: 303 errmsg: "Feature not supported: $text" message: "Feature not supported: $text" name: "MongoError"enter code here ok: 0


Solution

  • The "MongoDB 3.6 compatibility" means DocumentDB supports some of MongoDB 3.6 features. There are many MongoDB features that DocumentDB does not implement, $text appears to be one of them.

    https://www.mongodb.com/atlas-vs-amazon-documentdb

    To get around this, use MongoDB.