MongoDB: custom query

Viewed 79

I have a nodejs application in which people will search for random articles. The articles rely on a MongoDB with the following main schema:

articles_table - title
               - description
               - content

The return of articles must be done algorithmically for reliability:

  1. I must split the search query into separated words
  2. I must search for articles containing the words in columns: title, description, content
  3. I must greedy count the found words in each column (title, description, content)
  4. I must order the results based on the count performed at dot 3 and then return them sorted

I could perform dots 1,2 on MongoDB and 3,4 on Nodejs. However I'd like to know if it's possible to do all these tasks directly in Mongo. If so, how could I do it?

0 Answers
Related