node.jsmongodbmongoosemongoose-plugins

Error: text search not enabled:- in mongodb


I get the following error :-

[Error: text search not enabled]

I am running the folliowing function which is essentially a mongoose-mongodb operation.

var textSearch = require('mongoose-text-search');

exports.dbTextSearch = function () {
    console.log('dbTextSearch');
    var gameSchema = mongoose.Schema({
        name: String
      , tags: [String]
      , likes: Number
      , created: Date
    });

    gameSchema.plugin(textSearch);

    gameSchema.index({ tags: 'text' });

    var Game = mongoose.model('Game', gameSchema);

    Game.create({ name: 'Super Mario 64', tags: ['nintendo', 'mario', '3d'] }, function (err) {
    Game.textSearch('3d', function (err, output) {
        if (err) return console.log(err); // this outputs the error.
        var inspect = require('util').inspect;
      console.log(inspect(output, { depth: null }));
        });
    });
}

I am trying to implement the mongoose-text-search plugin


Solution

  • MongoDB Text search is still an experimental feature. That's why it is disabled by default and must be enabled manually. You can do so by either starting mongod with the command line parameter --setParameter textSearchEnabled=true or adding the line textSearchEnabled=true to the file mongodb.conf.

    Please note that as an experimental feature, text search should not be used in a production environment yet.

    UPDATE

    As of version 2.6 of mongoDB text search feature has production-quality and is enabled automatically.