Search code examples
javatwitter4j

Filtering tweets based on both locations and track keywords


I am trying to filter the streaming by location and track words that I know that they are combined with an OR condition.

But, I would like to filter the tweets with an AND condition, such as tweets from a certain location that contain certain tracked words.

Is that possible? Can someone suggest me a way to do this?


Solution

  • No, it's not possible. It only works as logical OR.

    You can track keywords (don't track location here) and in the statuslistener check the tweets location.

    public void onStatus(Status status) {
      if(status.getGeoLocation != null) {
        double latitude = status.getGeoLocation.getLatitude();
        double longitude = status.getGeoLocation.getLongitude();
        // use these values
      }
    }