I'm trying to perform a full text search on a database on mLab. However, apparently the text indexes are not being created. Mongoose version is 5.4.16
Schema:
var mongoose = require("mongoose");
var Schema = mongoose.Schema;
var mySchema = new Schema({
title: {
type: String,
trim: true,
required: true
},
description: {
type: String,
trim: true
}
});
mySchema.index({
title: "text",
description: "text",
});
mongoose.model("Model", mySchema);
module.exports = mongoose.model("Model");
Use following to perform the search:
Model.find({
$text: { $search: query }
}).exec(function(err, codes) {...}```
I get the following error:
MongoError: text index required for $text query