dreamcatcher

Untitled

Nov 11th, 2014
171
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.77 KB | None | 0 0
  1. ---Belli bir konuyu araştırmak istediğimizde aratmak istediğimiz tweet
  2.  
  3. db.TwitterStatus.find({"searchID":ObjectId("546147f6177d9b2cb8c2cee6")})
  4.  
  5. ----Kaç adet tweet atıldığını görmek için Kod:
  6.  
  7. db.TwitterStatus.count({"searchID":ObjectId("546147f6177d9b2cb8c2cee6")})
  8.  
  9. — Bir ID içinde bir kullanıcı hesabı kaç kere mention edilmiş bulmak için:
  10.  
  11. db.TwitterStatus.aggregate(
  12. {$match: {"searchID":ObjectId("546147f6177d9b2cb8c2cee6")}},
  13. {$unwind:"$Status.EntitiesExt.UserMentionEntities"},
  14. {$group:{_id:"$Status.EntitiesExt.UserMentionEntities.ScreenName",count:{$sum:1}}},
  15. {$sort:{"count":-1}}
  16. )
  17.  
  18. —— Birden fazla ID’li toplu atılan tweetlerin sayısını öğrenmek için
  19.  
  20. db.TwitterStatus.count({
  21. $or:
  22. [
  23. {"searchID":ObjectId("546147f6177d9b2cb8c2cee6")},
  24. {"searchID":ObjectId("546147f6177d9b2cb8c2cee6")},
  25. {"searchID":ObjectId("546147f6177d9b2cb8c2cee6")}
  26. ]})
  27.  
  28.  
  29. ——— Toplam kaç user tweet attı sorgu (Bu unique sonuç verir. Yani A kullanıcı 2 tweet atsa bile 1 diye geçer.)
  30.  
  31. db.TwitterStatus.aggregate(
  32. {$match:{ $or:
  33. [
  34. {"searchID":ObjectId("546147f6177d9b2cb8c2cee6")},
  35. {"searchID":ObjectId("546147f6177d9b2cb8c2cee6")},
  36. {"searchID":ObjectId("546147f6177d9b2cb8c2cee6")}]}},
  37. {$group:{_id:"$Status.User.UserIDResponse"}},
  38. {$group:{_id:1,count:{$sum:1}}})
  39.  
  40. —— önce bunu kullan RT
  41.  
  42.  
  43. //Bu RT'li mesajları gruplar. Retweetlnmiş aynı mesajlar kendini tekrar etmez.
  44. //Sorguda okumanı kolaylaştırır (bunu öneririm)
  45. db.TwitterStatus.aggregate(
  46. {$match: {"searchID":ObjectId("546147f6177d9b2cb8c2cee6")}},
  47. {$group:
  48. {_id:"$Status.RetweetedStatus.StatusID",
  49. "Text": { $last : "$Status.Text"},
  50. "RetweetStatus": {$max : "$Status.RetweetedStatus.RetweetCount"}}},
  51. {$sort:{"RetweetStatus":-1}}
  52. )
  53.  
  54. —— Tekil olarak en fazla RT almış mesaj sorgusu
  55.  
  56. db.TwitterStatus.find({"searchID":ObjectId("546147f6177d9b2cb8c2cee6")})
  57. .sort({"Status.RetweetedStatus.RetweetCount":-1}).limit(100)
  58.  
  59.  
  60. ——— En fazla rt alan mesajlar
  61.  
  62. db.TwitterStatus.find({
  63. $or:
  64. [
  65. {"searchID":ObjectId("546147f6177d9b2cb8c2cee6")},
  66. {"searchID":ObjectId("546147f6177d9b2cb8c2cee6")},
  67. {"searchID":ObjectId("546147f6177d9b2cb8c2cee6")},
  68. {"searchID":ObjectId("546147f6177d9b2cb8c2cee6")}
  69. ]})
  70. .sort({"Status.RetweetedStatus.RetweetCount":-1}).limit(100)
  71.  
  72. ————— En fazla favorite alan mesaj
  73.  
  74. db.TwitterStatus.find({
  75. $or:
  76. [
  77. {"searchID":ObjectId("546147f6177d9b2cb8c2cee6")},
  78. {"searchID":ObjectId("546147f6177d9b2cb8c2cee6")},
  79. {"searchID":ObjectId("546147f6177d9b2cb8c2cee6")},
  80. {"searchID":ObjectId("546147f6177d9b2cb8c2cee6")}
  81. ]}).limit(10)
  82. .sort({"Status.RetweetedStatus.FavoriteCount":-1})
  83.  
  84.  
  85.  
  86.  
  87. ———— En fazla Tweet almış hashtag
  88.  
  89. db.TwitterStatus.aggregate(
  90. {$match: {"searchID":ObjectId("546147f6177d9b2cb8c2cee6")}},
  91. {$unwind:"$Status.EntitiesExt.HashTagEntities"},
  92. {$group:{_id:"$Status.EntitiesExt.HashTagEntities.Tag",count:{$sum:1}}},
  93. {$sort:{"count":-1}}
  94. )
  95.  
  96.  
  97. ————— Birden fazla ID’li çalışma için hashtag araması
  98.  
  99. db.TwitterStatus.aggregate(
  100. {$match: {$or:
  101. [
  102. {"searchID":ObjectId("546147f6177d9b2cb8c2cee6")},
  103. {"searchID":ObjectId("546147f6177d9b2cb8c2cee6")},
  104. {"searchID":ObjectId("546147f6177d9b2cb8c2cee6")}
  105. ]}},
  106. {$unwind:"$Status.EntitiesExt.HashTagEntities"},
  107. {$group:{_id:"$Status.EntitiesExt.HashTagEntities.Tag",count:{$sum:1}}},
  108. {$sort:{"count":-1}}
  109. )
  110.  
  111. ———— 100 limitlii
  112.  
  113.  
  114. db.TwitterStatus.aggregate(
  115. {$match: {$or:
  116. [
  117. {"searchID":ObjectId("546147f6177d9b2cb8c2cee6")},
  118. {"searchID":ObjectId("546147f6177d9b2cb8c2cee6")},
  119. {"searchID":ObjectId("546147f6177d9b2cb8c2cee6")}
  120. ]}},
  121. {$unwind:"$Status.EntitiesExt.HashTagEntities"},
  122. {$group:{_id:"$Status.EntitiesExt.HashTagEntities.Tag",count:{$sum:1}}},
  123. {$sort:{"count":-1}},
  124.  
  125. {$limit:100}
  126. )
  127.  
  128. —— Keyword içinde bir ismin kaç kere geçtiği
  129.  
  130. db.TwitterStatus.count({$and:[{"searchID":ObjectId("546147f6177d9b2cb8c2cee6")},{"Status.Text": /Muslera/i }]})
  131.  
  132. Mentionlanan ve bir ismin kaç kere geçtiğine bakmak için
  133.  
  134. db.TwitterStatus.count({$and :[{"searchID":ObjectId("546147f6177d9b2cb8c2cee6")},
  135. {
  136. $or:[
  137. {"Status.Text": { $regex: /muslera/i } },
  138. {"Status.Text": { $regex: /1_Muslera_25/i } }
  139. ]
  140. }]})
  141.  
  142.  
  143.  
  144. -Toplu Olarka Bakmak İstersek (Bunu Kullan )
  145.  
  146. db.TwitterStatus.count({$and :[
  147. {
  148. $or:[
  149. {"searchID":ObjectId("546147f6177d9b2cb8c2cee6")},
  150. {"searchID":ObjectId("546147f6177d9b2cb8c2cee6")}
  151. ]
  152. },
  153. {
  154. $or:[
  155. {"Status.Text": { $regex: /Gökhan Töre/i } },
  156. {"Status.Text": { $regex: /Gokhan Tore/i } },
  157. {"Status.Text": { $regex: /Töre/i } }
  158. ]
  159. }]})
Advertisement
Add Comment
Please, Sign In to add comment