本文介绍了错误:未启用文本搜索:-在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 插件
推荐答案
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中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!