如何获取twitter返回的twitter4j关键字?

myzjeezk  于 2021-06-21  发布在  Storm
关注(0)|答案(1)|浏览(372)

我正在构建一个系统,它使用apachestorm和twitter4j库来处理实时twitter。但我有一个问题:有没有办法知道哪个关键词过滤器给了我那条微博?
例子:

//Topology builder parameter
String keywords = {"Keyword 1", "Keyword 2"};

//Call of Twitter strem API return
  @Override
  public void execute(Tuple tuple, BasicOutputCollector collector) {
      Status status = (Status) tuple.getValueByField("tweet");
      System.out.println(status);
  }

//Result of Sysout
StatusJSONImpl{createdAt=Thu Aug 20 16:55:52 BRT 2015, id=645265788760587264, text='RT @user: This is a Keyword 1 tweet' ... }

StatusJSONImpl{createdAt=Thu Aug 20 16:55:56 BRT 2015, id=645265788760587265, text='RT @user: This is a Keyword 2 tweet' ... }

我怎么知道在没有字符串比较的情况下使用了哪个关键字?我没有找到任何具有关键字的对象属性,只有tweet数据。

jk9hmnmh

jk9hmnmh1#

twitter流式api只返回标准tweet有效负载,它不会添加任何与查询相关的额外元数据。唯一的方法就是根据关键字列表处理消息客户端。

相关问题