Reputation: 2554
I am using Twitter4j streaming API. I am using a geolocation constraint to get the tweets only from a specific area. Here is that part of the code:
twitterStream.addListener(listener);
String[] keywordsArray = { "iphone", "america", "samsung" };
FilterQuery filterQuery = new FilterQuery();
filterQuery.track(keywordsArray);
double[][] locations = { { 40.714623d, -74.006605d },
{ 42.3583d, -71.0603d } };
filterQuery.locations(locations);
twitterStream.filter(filterQuery);
This actually returns me results but almost all the tweets come with geolocation as NULL. One out of 25-30 (or even more)tweets will have a geotag. Can anyone point me to what am I missing?
Upvotes: 2
Views: 3118
Reputation: 86
As far as I know, twitter streaming API does not allow searching by both keyword AND location. Your code is searching for tweets which either have the keywords:{ "iphone", "america", "samsung" } OR belong to the location: { { 40.714623d, -74.006605d },{ 42.3583d, -71.0603d } }. Hence the tweets that you are getting which have a geo tag are the ones which belong to the given location while others are due to the given keywords.
Upvotes: 3