【问题标题】:Get all tweets based on SPECIFIC word and STORE all tweets in SINGLE BAG获取基于特定单词的所有推文并将所有推文存储在 SINGLE BAG 中
【发布时间】:2016-08-31 08:28:37
【问题描述】:

我正在尝试处理示例推文并根据过滤条件存储推文。

例如,

推文示例:-

{"created_time": "18:47:31 ", "text": "RT @Joey7Barton: ..give a word about whether the americans wins a Ryder cup. I mean surely he has slightly more important matters. #fami ...", "user_id": 450990391, "id": 252479809098223616, "created_date": "Sun Sep 30 2012"}

twitter = LOAD 'Tweet.json' USING JsonLoader('created_time:chararray, text:chararray, user_id:chararray, id:chararray, created_date:chararray');
grouped = GROUP twitter BY (text,id);
filtered =FOREACH grouped { row = FILTER $1 BY (text MATCHES '.*word.*'); GENERATE FLATTEN(row);}

它得到与单词匹配的完整推文。

但我需要得到如下输出:

(word)(all tweets of contained that word)

我怎样才能做到这一点?

任何帮助。

莫汉.V

【问题讨论】:

    标签: json hadoop apache-pig hadoop-streaming


    【解决方案1】:

    过滤后,将单词作为字段添加到过滤后的关系中,然后按该字段分组。这将为您提供单词和一袋推文。

    twitter = LOAD 'Tweet.json' USING JsonLoader('created_time:chararray, text:chararray, user_id:chararray, id:chararray, created_date:chararray');
    grouped = GROUP twitter BY (text,id);
    filtered =  FILTER $1 BY (text MATCHES '.*word.*');
    newfiltered = FOREACH filtered GENERATE 'word' AS pattern,filtered.text;
    final = GROUP newfiltered BY pattern;
    DUMP final;
    

    【讨论】:

    • 感谢您的回复 inquisitive_mind。我正在尝试另一种方案。即
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-10-08
    • 2018-01-25
    • 2017-01-05
    相关资源
    最近更新 更多