[MONGO] mongoose find using multiple text - fourslickz/notes GitHub Wiki

const keywords = "keyword1 keyword2";

BlogPost.find(
  { $text: { $search: keywords } },
  { score: { $meta: "textScore" } }
)
.sort({ score: { $meta: "textScore" } })
.then(posts => {
  console.log('Found posts:', posts);
})
.catch(err => {
  console.error('Error fetching posts:', err);
});