Hello!
I enabled textSearch in Mongodb and now want to use it via mongoose in my node js application.
My Schema looks like this:
var mongoose = require('mongoose');
mongoose.connect('mongodb://localhost/products');
var productDB = mongoose.connection.db;
var Schema = mongoose.Schema;
var ProductSchema = new Schema({
name : {
type : String,
required : true,
unique : true,
},
unitprice : {
type : Number,
required : true
},
description : {
type : String,
trim : true,
},
discontinued : {
type : Boolean
},
tags : {
type : [String],
index : "text"
}
});
var Product = mongoose.model('Product', ProductSchema);
On the command line, I can use the text search like this:
db.products.runCommand("text", {search: "someSearchString"})
and it works fine.
Now I tried it in my app like described
here, assuming that text defines the collection name, what seems quite strange to me...
productDB.command({
text: "products",
search : req.body.searchstring,
limit : 50
},...
but I don't get any results :(
Any suggestions?
Kind regards!