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:
- I must split the search query into separated words
- I must search for articles containing the words in columns: title, description, content
- I must greedy count the found words in each column (title, description, content)
- 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?