Map-Reduce Using MongoDB

What is MongoDB?

Database

Collection

Document

What is the aggression framework?

Map-Reduce

Step 1: Installing MongoDB

https://fastdl.mongodb.org/windows/mongodb-windows-x86_64-4.4.6-signed.msi

Step 2: Installing MongoDB tools

https://fastdl.mongodb.org/tools/db/mongodb-database-tools-windows-x86_64-100.3.1.msi

Step 3: Setting up environment variables path for using MongoDB server and database tools from CLI.

Step 4: Using map-reduce function in MongoDB

https://github.com/GulshaChawla2608/Task_34_MongoDB
  1. Persons
  2. Deck Of Cards

Example 1: Persons

Persons
>>mongoimport persons.json -d Persons -c peoples --jsonArray
DB & Collection Created
Aggregation Pipeline
>>var mapFunc2=function(){var peeps=emit(this.gender,this.age);$split:[peeps,”,”];};
var reduceFunc2=function(keyGender,valuesAge){return valuesAge.length;};
db.collection-name.mapReduce(mapFunc2,reduceFunc2,{out:”map_reduced”})
Map-Reduce Program

Example 2: Deck Of Cards

Deck Of Cards
>>mongoimport cards.json -d deck_of_cards -c cards--jsonArray
Data Imported in DB
Aggregation Pipeline

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store