Suppose that I have the below simplified schema:
const Venue = new mongoose.Schema(
{
name: {
en: { type: String, required: true }, // English translation
fr: { type: String, required: true }, // French translation
es: { type: String, required: true }, // Spanish translation
sw: { type: String, required: true },
},
country: {
en: { type: String, required: true }, // English translation
fr: { type: String, required: true }, // French translation
es: { type: String, required: true }, // Spanish translation
sw: { type: String, required: true },
},
countryIso3: String,
},
{ collection: 'Venues', timestamps: true }
);
export default mongoose.models.Venue || mongoose.model('Venues', Venue);
So, I want to use one index definition that support dual-purpose fields (autocomplete + text search). How to do that by providing also the highlight score and inject the score boost during aggregation?