Guest User

Source

a guest
Apr 21st, 2014
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.86 KB | None | 0 0
  1. JSON SOURCE
  2. =============
  3. {
  4. "took" : 3,
  5. "timed_out" : false,
  6. "_shards" : {
  7. "total" : 5,
  8. "successful" : 5,
  9. "failed" : 0
  10. },
  11. "hits" : {
  12. "total" : 5,
  13. "max_score" : 2.252763,
  14. "hits" : [ {
  15. "_index" : "twitter",
  16. "_type" : "tweet",
  17. "_id" : "458132986852958208",
  18. "_score" : 2.252763, "_source" : {"text":"RT @AhmasZain: Massive respect to #mh192 pilot? He's only doing his job,job well done. What about the garbage collector doing his job? No m…","tweet_sentiment":1,"created_at":"2014-04-21T06:39:50.000Z","source":"<a href=\"http://twitter.com/download/iphone\" rel=\"nofollow\">Twitter for iPhone</a>","truncated":false,"mention":[{"id":354484183,"name":"Ahmas Zain","screen_name":"AhmasZain"}],"retweet_count":0,"retweet":{"id":458076965124075520,"user_id":354484183,"user_screen_name":"AhmasZain","retweet_count":1},"hashtag":[{"hashtag_text":"mh192"}],"link":[],"user":{"id":593217546,"name":"S.Devaraj","screen_name":"devaraaj17","location":"Australia, BNE. ","description":"If you wanna get with me,\nThere's some things you gotta know;\nI like my beats fast,\nAnd my bass down low."}}
  19. }, {
  20. "_index" : "twitter",
  21. "_type" : "tweet",
  22. "_id" : "458132982365036544",
  23. "_score" : 1.4054651, "_source" : {"text":"What happen ? #MH192","tweet_sentiment":2,"created_at":"2014-04-21T06:39:49.000Z","source":"<a href=\"http://twitter.com/#!/download/ipad\" rel=\"nofollow\">Twitter for iPad</a>","truncated":false,"mention":[],"retweet_count":0,"hashtag":[{"hashtag_text":"MH192"}],"link":[],"user":{"id":386339267,"name":"mileymana","screen_name":"manarina_SS","location":"BANGERZ Tour","description":"23rd June 98. A Smiler. Miley Cyrus ❤️ IG- manarina_m Imagine Dragons"}}
  24. }, {
  25. "_index" : "twitter",
  26. "_type" : "tweet",
  27. "_id" : "458132919685378048",
  28. "_score" : 1.287682, "_source" : {"text":"STOP LA SIA PASAL #MH192 THAT FLIGHT DAH LAMA SAFELY LANDED. YG LU ORG SEMUA NK SPREAD LAGI FAKE NEWS WTF LA SIA!","tweet_sentiment":1,"created_at":"2014-04-21T06:39:34.000Z","source":"<a href=\"https://twitter.com/download/android\" rel=\"nofollow\">Twitter for Android</a>","truncated":false,"mention":[],"retweet_count":0,"hashtag":[{"hashtag_text":"MH192"}],"link":[],"user":{"id":914540778,"name":"garrix.","screen_name":"akemwilson","location":"ig: akemwilson | JHB-MLK","description":"20. #halamadrid"}}
  29. }, {
  30. "_index" : "twitter",
  31. "_type" : "tweet",
  32. "_id" : "458133042427469824",
  33. "_score" : 1.287682, "_source" : {"text":"RT @MyschaMorgana: #MH192 tyre burst out last night >.< http://t.co/CpHo9bgYn8","tweet_sentiment":1,"created_at":"2014-04-21T06:40:03.000Z","source":"<a href=\"http://twitter.com/download/android\" rel=\"nofollow\">Twitter for Android</a>","truncated":false,"mention":[{"id":318342349,"name":"♥Naya Na Honey♥","screen_name":"MyschaMorgana"}],"retweet_count":0,"retweet":{"id":458122907579715584,"user_id":318342349,"user_screen_name":"MyschaMorgana","retweet_count":14},"hashtag":[{"hashtag_text":"MH192"}],"link":[],"user":{"id":2274572706,"name":"amiricious khan ∞","screen_name":"PKreko","location":"","description":"Seventeen♡ Full time daughter ♡ past, present, future. 10.11.2012 & 20.01.2013, insyaAllah✌"}}
  34. }, {
  35. "_index" : "twitter",
  36. "_type" : "tweet",
  37. "_id" : "458133204327612416",
  38. "_score" : 1.1976817, "_source" : {"text":"RT @izreloaded: Passengers of #MH192 will be making their next flight to Bangalore, India at 3pm today. #PrayForMH192","tweet_sentiment":1,"created_at":"2014-04-21T06:40:42.000Z","source":"<a href=\"https://mobile.twitter.com\" rel=\"nofollow\">Mobile Web (M2)</a>","truncated":false,"mention":[{"id":8934712,"name":"IZ Reloaded","screen_name":"izreloaded"}],"retweet_count":0,"retweet":{"id":458110420507566080,"user_id":8934712,"user_screen_name":"izreloaded","retweet_count":2},"hashtag":[{"hashtag_text":"MH192"},{"hashtag_text":"PrayForMH192"}],"link":[],"user":{"id":420761335,"name":"Steve Einstein","screen_name":"MrSteveEinstein","location":"Malaysia ","description":"Capable of anything & everything. Student, Best Actor 2013 English Drama team, Loves Acting, Dramas & Movies. Full-time dreamer. INSTAGRAM: IAMSTEVE_EINSTEIN96"}}
  39. } ]
  40. }
  41. }
  42.  
  43. hashtag based search
  44. ====================
  45. String[] hastags = request.getHashTags().split(",");
  46. FilterBuilder[] hashTagFilter = new FilterBuilder[hastags.length];
  47. for(int i=0;i<hastags.length;i++){
  48. String hashtag = hastags[i];
  49. hashTagFilter[i] = FilterBuilders.nestedFilter("hashtag", FilterBuilders.termFilter("hashtag_text", hashtag));
  50. }
  51. srb.setQuery(QueryBuilders.filteredQuery(QueryBuilders.matchAllQuery(), FilterBuilders.orFilter(hashTagFilter)));
  52.  
  53.  
  54. User name search
  55. ================
  56. srb.setQuery(QueryBuilders.filteredQuery(QueryBuilders.matchAllQuery(), FilterBuilders.termFilter("screen_name", request.getFromUser())));
Advertisement
Add Comment
Please, Sign In to add comment