Can't exclude retweets from searches

Sep 17, 2011 at 1:18 AM

Hey,

 

I can't seem to exclude retweets in my searches, even with WithRetweets == false. It returns the same amount of tweets when it's true as it does when it's false. I can see the "RT @..." in the tweetdata I get in, and compare it with them as they are on Twitter.com and they are proper retweets and not just mentions.

 

Cheers

Coordinator
Sep 19, 2011 at 5:25 AM

Hi,

With so many properties that have the word "Retweet" in them, it's understandable that this isn't more clear.  Are you using the Status/Home query?  It includes retweets by the authenticated user.  Though Twitter will always send the retweet for Status/Home queries, you can filter it out of your results with LINQ to Twitter.  The Status instance has a Retweet property that is null if the Status isn't a retweet or is a Retweet instance if the Status is a retweet.  So, you can use the following query to filter it out:

            var homeTweets =
                from tweet in twitterCtx.Status
                where tweet.Type == StatusType.Home &&
                      tweet.Retweet == null
                select tweet;

Another option is to use Status/User queries, which does not include retweets by default, but let me qualify that.  Twitter has a formal definition of what a retweet is - which is when someone clicks the Retweet button in the UI.  Placing an RT in front of a tweet is not the same as a Twitter retweet.  So, that means you'll always see tweets that start with RT, but not the Twitter retweets.  To get the Twitter retweets, you must add the IncludeRetweets == true filter.  IncludeRetweets has no effect on Status/Home queries, but is available for Status/User queries, which don't include retweets by default.  Now, let me add more confusion to the process - Status/User queries that have IncludeRetweets set to true have Retweet instances populated for both Status' with RT and Twitter Retweets.  So, one trick would be to do a Status/User query with Retweet == null, as in the example above, to filter out all retweets; but, remember that Twitter is still sending everything accross the wire and LINQ to Twitter is letting you filter it out of the results.

Joe

Oct 24, 2012 at 8:31 AM

I'm having the same issue as jbfp10

I'm using twitterCtx.Search like this - !search.WithRetweets - expecting that RT tweets will be filtered out, however they still appear in the results.

Thanks!

Coordinator
Oct 24, 2012 at 12:13 PM
This discussion has been copied to a work item. Click here to go to the work item and continue the discussion.
Coordinator
Oct 24, 2012 at 12:15 PM

I copied this to a work item to take a closer look at what's happening here. In the meantime, use WithRetweets like this: "search.WithRetweets == false".

Joe