[Mongodb]mapreduce

Source: Internet
Author: User
Tags emit mongodb server

Summary

The previous article introduced several simple aggregation operations for COUNT,GROUP,DISTINCT, where group was a bit more troublesome. This article will learn about the relevant content of MapReduce.

Related articles

Getting started with [MongoDB]

[MongoDB] additions and deletions change

[Mongodb]count,gourp,distinct

Bat

Today suddenly found that every time the MongoDB server and client open, too often. So think of a way to get them to batch order.

Open Server

" cd/d C:\Program Files\mongodb\server\3.2\bin&&mongod "

After execution

Start Client

" cd/d C:\Program Files\mongodb\server\3.2\bin&&mongo "

After execution

Here is a small episode, some things, repeated do not need, can be labor-saving effort. Of course some MongoDB visualization client tools are more convenient. Several commonly used tools will be introduced later.

Mapreduce

The function of MapReduce is also one of the aggregation functions, why it is listed separately, because it is too complex with the group of a spell.

In fact, the function is easier to remember, because it has two parameters, one is map, the other is reduce

Map

mapping function, in which emit (Key,value) is called, and the collection is grouped according to the key you specify.

Reduce

The simplification function simplifies grouping the data after the map is grouped, and the key in reduce (Key,value) is the set of emit (value) in emit that Key,vlaue is grouped by emit.

Result: The collection name that is deposited.

Input: The number of document passed in.

Reduce: The number of times this function was called.

Emit: The number of times this function was called.

Output: The number of results for the outputs.

The result can then be queried by name after the query is grouped.

About the cmd input command line, here is also a simple introduction, such as the above map and reduce function is very long, then we can carry on the input, technique: input, do not enter the end of the symbol can be, such as function of the end of the symbol, as long as not lose people}, Enter the time, will print ..., this time you can continue to input.

We do the above MapReduce operation by line break.

It's more comfortable to look at.

Summarize

There are a lot of things about MapReduce, and here are just a few examples of how mapreduce is used. For more information, refer to the following article

MapReduce Baidu Encyclopedia

Http://www.cnblogs.com/daizhj/archive/2010/06/10/1755761.html

Http://www.cnblogs.com/huangxincheng/archive/2012/02/21/2361205.html

Http://www.cnblogs.com/loogn/archive/2012/02/09/2344054.html

[Mongodb]mapreduce

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.