I am trying to add mongoose-text-search to my first plugin .
https://npmjs.org/package/mongoose-text-search
I get an error: How to Error: text search not enabled , which I cannot understand.
I have my schema in a separate file, where it is compiled into a model that I export. (Works great.) BlogSchema.js
var mongoose = require('mongoose'); var textSearch = require('mongoose-text-search'); var blogSchema = new mongoose.Schema({ title: String, author: String, }], });
This is the appropriate code for the server side. When the client sends a request to / search /, the socket hangs up - Got error: socket hang up , and on the server side I get a How to 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.
source share