San*_*ngh 6 mongoose mongodb node.js mongoose-plugins
我收到以下错误: -
[Error: text search not enabled]
Run Code Online (Sandbox Code Playgroud)
我正在运行folliowing函数,它本质上是一个mongoose-mongodb操作.
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 }));
});
});
}
Run Code Online (Sandbox Code Playgroud)
我正在尝试实现mongoose-text-search插件
Sea*_*ory 16
在MongoDB 2.4中 - 启用实验文本搜索,使用
setParameter=textSearchEnabled=true
以下行在mongodb.conf文件中对我不起作用.
textSearchEnabled=true
编辑在MongoDB 2.6 +中默认启用.您只需要设置文本索引.
归档时间: |
|
查看次数: |
5154 次 |
最近记录: |