// create the twitter stream factory with the config
TwitterStreamFactory fact =
new TwitterStreamFactory(config.build());
// get an instance of twitter stream
twitterStream = fact.getInstance();
FilterQuery tweetFilterQuery = new FilterQuery(); // See
tweetFilterQuery.locations(new double[][]{new double[] {-124.848974,24.396308},
new double[]{-66.885444,49.384358
}});
tweetFilterQuery.language(new String[]{"en"});
tweetFilterQuery.track(new String[]{"sony", "apple" });
// provide the handler for twitter stream
twitterStream.addListener(new TweetListener());
twitterStream.filter(tweetFilterQuery);
// start the sampling of tweets
//twitterStream.sample();
在twitter spout中我只想要包含apple或sony字样的推文,我尝试过tweetFilterQuery.track()。我只需要包含索尼和苹果字的推文。