I'm programming a meteor app and I need some advice in how can I do the following. I have a collection called Articles
which it has newspaper articles. My idea is to create a map where every key points to a group of articles that has that word in it's title.
For example:
/* Article 1 */
{
"_id" : "SB4mKAxaBijQXnS73",
"title" : "Messi signs new contract with Barcelona"
}
/* Article 2 */
{
"_id" : "rhqioBkePzGCrRFLp",
"title" : "Messi is from Argentina"
}
/* Article 3 */
{
"_id" : "X6LochRZw32op39W8",
"title" : "President of Argentina visits Messi"
}
Then I will have:
Messi ==> [Article 1, Article 2, Article 3]
signs ==> [Article 1]
new ==> [Article 1]
contract ==> [Article 1]
with ==> [Article 1]
Barcelona ==> [Article 1, Article 3]
is ==> [Article 2]
from ==> [Article 2]
Argentina ==> [Article 2, Article 3]
President ==> [Article 3]
of ==> [Article 3]
visits ==> [Article 3]
Then I need to only return the tuple (key, array) where:
- Keyword has more than 3 letters (This I can avoid it if I check the length of the word before using it as a key)
- Group has more than 1 Article.
My idea then is to iterate over that array and show it in the template, for that reason I need to do it in a template helper.