caarlos0
caarlos0

Reputation: 20633

MongoID: Group and Count

Supposing I have a model Post, wich contains only the field desc.

The user can use hashtags, like #rails inside any posts...

How can I list and count the hashtags used, for example, in the last 10 days?

I'm do not know much about mongodb, but I see that I could use something called map_reduce.. have no idea why/how.

Thanks in advance.

Upvotes: 2

Views: 1276

Answers (1)

Luiz E.
Luiz E.

Reputation: 7229

You are right...this can be solved using mad/reduce function...
try this or this gem if you dont want to think a lot lol

https://github.com/jcoene/mongoid-mapreduce

Upvotes: 1

Related Questions