node.js - Installing plugins for mongoose - getting error -
i'm trying add in first plugin - mongoose-text-search.
https://npmjs.org/package/mongoose-text-search
i'm getting error: how error: text search not enabled
can't figure out.
i have schema in seperate file gets compiled model export. (works fine.) blogschema.js
var mongoose = require('mongoose'); var textsearch = require('mongoose-text-search'); var blogschema = new mongoose.schema({ title: string, author: string, }], }); // give our schema text search capabilities blogschema.plugin(textsearch); var blog = mongoose.model('blog', blogschema); exports.blog = blog;
this relevant code server side. when client sends request /search/, socket hangs - got error: socket hang up
, on server side how error: text search not enabled
message.
server.js
var express = require('express') , mongoose = require('mongoose') , textsearch = require('mongoose-text-search'); var search_options = { project: 'title -_id' }; app.get('/search', function (req, res) { console.log("inside text search"); reading.textsearch('writing', search_options, function (err, output) { if (err) throw err; console.log(output); }); });
thanks.
you need enable text search on mongodb server described here it's disabled default.
Comments
Post a Comment