As I find out, since version 3.8.9, mongoose support full text search. But I can't find a good documentation for it!
I want to do something like:
db.collection.ensureIndex(
// Fields to index
{
animal: "text",
color: "text",
pattern: "text",
size: "text"
},
// Options
{
name: "best_match_index",
// Adjust field weights (default is 1)
weights: {
animal: 5, // Most relevant search field
size: 4 // Also relevant
}
}
)
Can I do it with pure mongoose? Or I have to use some plugin like mongoose-text-search? How about without weight?
And how should I do it?
index
on the schema to add the text index? – Stanislasindex
method of your schema. mongoosejs.com/docs/api.html#schema_Schema-index – Stanislas