-
Notifications
You must be signed in to change notification settings - Fork 0
/
comandos.txt
53 lines (43 loc) · 1.36 KB
/
comandos.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#1.1
db.tweets.find({id:1,text:1}).limit(10)
#1.2
db.tweets.find({},{id:1,text:1}).limit(10)
#1.3
db.tweets.find({"user.followers_count":{"$gt":10000}},{id:1, "user.name":1, "user.description":1, "user.followers_count":1})
#1.4
db.tweets.find({"user.followers_count":{"$gt":10000}},{id:1, "user.name":1, "user.followers_count":1}).sort({"user.followers_count":-1}).limit(10)
#2.1
db.tweets.mapReduce(function(){emit(this.source,1);},function(source,value){return Array.sum(value)},{out:{inline:1}})
#2.2
db.tweets.mapReduce(function(){emit(this.lang,1);},function(lang,value){return Array.sum(value)},{out:{inline:1}})
#2.3
db.tweets.mapReduce(
function() {
var palabras = this.text.split(" ");
var cantidadPalabras = palabras.length;
if (cantidadPalabras < 10) {
emit("textoCorto", 1);
} else if (cantidadPalabras >= 20) {
emit("textoLargo", 1);
} else {
emit("textoMediano", 1);
}
},
function(key, values) {
return Array.sum(values);
},
{
out: { inline: 1 }
}
)
#3.1
db.tweets.aggregate(
{"$group": {"_id": "$user.name", "count": {"$sum": 1} } },
{"$sort": {"count": -1} },
{"$limit": 10}
)
#3.2
db.tweets.aggregate(
{"$group": {"_id": "$lang", "maxFollowersCount": {"$max": "$user.followers_count"} } },
{"$sort": {"maxFollowersCount": -1}}
)