This project has moved and is read-only. For the latest updates, please go here.

Advanced Search

Dec 27, 2009 at 5:23 AM

I understand how to do basic searching on 1 term:

var tweets = from tweet in twitterDataContext.Search
                    where tweet.Type == SearchType.Search
                    && tweet.Query == searchTerm
                    select tweet;

Though is there a way to do advanced searches? (referenced from:



Dec 27, 2009 at 8:50 AM
This discussion has been copied to a work item. Click here to go to the work item and continue the discussion.
Feb 21, 2010 at 8:00 AM

Hi Daniel,

You can perform advanced queries by including search operators in your query.  Here's an example:

        /// <summary>
        /// shows how to perform a twitter search, using a Twitter Search operator
        /// </summary>
        /// <param name="twitterCtx">TwitterContext</param>
        private static void SearchOperatorDemo(TwitterContext twitterCtx)

            var queryResults =
                from search in twitterCtx.Search
                where search.Type == SearchType.Search &&
                      search.Query == "to:JoeMayo"
                select search;

            foreach (var search in queryResults)
                // here, you can see that properties are named
                // from the perspective of atom feed elements
                // i.e. the query string is called Title
                Console.WriteLine("\nQuery:\n" + search.Title);

                foreach (var entry in search.Entries)
                        "ID: {0}, Source: {1}\nContent: {2}\n",
                        entry.ID, entry.Source, entry.Content);

You can find the available operators at:

This will work in a lot of cases, but I'm still going to add special parameters for advanced queries, since the query itself can only contain 140 characters.