Writing map-reduce and aggregation to fetch and analyze data
The data is in the database now. However, we still need to read and analyze it. We will query our database in different ways and get the data based on this. We will track the total number of clicks on an article, the total number of impressions on an article, and the total number of unique impressions per day. We will use MongoDB queries and the
map-reduce function to achieve this.
The map-reduce function is a combination of two procedures:
- Map: This is a procedure that filters and sorts the records
- Reduce: This is an operation that performs the remaining function, for example, counting
Clicks and impressions increase really quickly in huge volumes, and normal queries can be too slow; the ...