'MongoDB Atlas - Boost search score from external list of words

I use MongoDB Atlas' full-text search which can boost the search score (how relevant a result is for that particular search query) by specifying the path that should be weighed more. Example:

text: {
   query: query,
   path: ["title"],
   allowAnalyzedField: true,
   score: { boost: { value: 2 } },
}

This will give results where the query appears in the "title" property a higher weight.

I want to do the same, but instead of specifying a path, I want to check if the query appears in an array of strings that I prepare beforehand. I want to weigh these words/phrases higher. How can I do that?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source