错误:未启用文本搜索:-在mongodb中 [英] Error: text search not enabled:- in mongodb

查看:60
本文介绍了错误:未启用文本搜索:-在mongodb中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我收到以下错误:-

[Error: text search not enabled]

我正在运行Folliowing函数,该函数本质上是mongoose-mongodb操作.

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 }));
        });
    });
}

我正在尝试实现 mongoose-text-search 插件

推荐答案

MongoDB文本搜索仍然是一项实验性功能.这就是为什么默认情况下禁用它,并且必须手动启用的原因.您可以通过使用命令行参数--setParameter textSearchEnabled=true启动mongod或将行textSearchEnabled=true添加到文件mongodb.conf中来实现.

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.

更新

从mongoDB版本2.6开始,文本搜索功能具有生产质量并已自动启用.

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

这篇关于错误:未启用文本搜索:-在mongodb中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆