Unable to fetch some tweets


We are using twitter4j latest version 4.0.x. We are unable to fetch tweets from my twitter account using search by keyword (Any of the keywords option).


Any example code? what error are you seeing? what are you searching for?

I assume since you posted this in the Streaming category you are using a filter by keyword on the public streaming endpoint?


We are using twitter4j 4.0.x and the code as follows

    private TwitterClient(String consumerKey, String consumerSecret,
            String accessToken, String accessTokenSecret) {
        ConfigurationBuilder cb = new ConfigurationBuilder();
        TwitterFactory tf = new TwitterFactory(cb.build());
        twitter = tf.getInstance();
        unauthenticatedTwitter = new TwitterFactory().getInstance();

    public static TwitterClient getInstance(String consumerKey,
            String consumerSecret, String accessToken, String accessTokenSecret) {
        String key = consumerKey;
        if (twitterClients.get(key) == null) {
            twitterClients.put(key, new TwitterClient(consumerKey,
                    consumerSecret, accessToken, accessTokenSecret));
        log.trace("Cache size = {}", twitterClients.size());

        return twitterClients.get(key);

public List<Status> searchTweets(String keyword) {
        String[] keywords = keyword.split(" ");
        String keywordWithOr = StringUtils.join(keywords, " OR ");
        Query searchQuery = new Query(keywordWithOr);

        return this.searchTweets(searchQuery);

public synchronized List<Status> searchTweets(Query query) {
        List<Status> tweets = new ArrayList<Status>(64);
        QueryResult result = null;

        try {
            result = twitter.search(query);
            List<Status> results = (ArrayList<Status>) result.getTweets();
        } catch (TwitterException e) {
            log.trace("Failed to search tweets: {}", e);

        return tweets;