close questionmark user search earth triangle retweet users star home mention pencil info lightbulb-o icon_fullscreen images refresh list grid mail in eye export twitter

Advanced Twitter search using query operators

27 March, 2016 by Tom

This article is designed to give an overview of the types of advanced Twitter searches you can perform within Twitter’s official search or using Social Bearing’s advanced search form

Tweets containing the word 'sunrise' in Indonesian (lang:in)

Tweets containing the word ‘sunrise’ in Indonesian (lang:in) using Social Bearing’s advanced Twitter search

The advanced Twitter search features allow you to search tweets from a specific language, date range, media type and more. Queries can also be built up using boolean operators such as AND and OR

All search features and operators described in this article can be used from Social Bearing’s advanced Twitter search feature, available at the bottom of the standard tweet search

Twitter search using Social Bearing's advanced options

Twitter search using Social Bearing’s advanced options

A regular Twitter search

Before we get to the good stuff, lets run over how a regular Twitter search works

A standard search will find and return tweets that match the keyword, hashtag, handle, URL or any other string of text searched for

Tweets are matched based on the content of the tweet; not only the textual content but will include the handle of the user tweeting or retweeting. Destination URL links within tweets are also matched, even if those links have been shortened for display purposes

If more than one word or hashtag has been search for, then tweets are matched against all search words, but in any order within the content of the tweet

Whole words are matched in a search and plurals are treated as if they were separate words. Searching for ‘cloud’ for example will not match tweets against ‘clouds’

Hashtags are treated slightly differently. A search for ‘cloud’ will find tweets with the hashtag ‘#cloud’ as well as ‘cloud’ but the opposite is not true; searching for ‘#cloud’ will only find tweets for that hashtag

Exact Match Searches

Enclosing keywords “within quotes” will perform an exact match search; treating multiple keywords as if it were a single string

In the Social Bearing search, you can select the ‘exact match’ option which will enclose the search term with quotes

Exact match search for tweets containing "space walk"

Exact match search for tweets containing “space walk”

As an example, if you wanted to find tweets mentioning the phrase space walk, you would probably want to use an exact match search “space walk”. Without using quotes, tweets would be returned for the words ‘space’ and ‘walk’ used anywhere within a tweet; the default search behaviour. A tweet containing the text ‘..walk around in this space..’ would probably not be relevant to this search

The OR operator

Using the OR operator would find tweets containing one word OR another. For example, the search phrase #sunrise OR sunset would find tweets containing either the hashtag #sunrise or the word sunset, in any order.

The ‘OR’ operator should be uppercase, otherwise the search will assume you were searching for the word ‘or’.

The AND operator

The ‘AND’ operator can be used in the same way as OR, but the use of this operator alone is treated in the same way as a regular search.

For example searching for ‘sunrise sunset’ or ‘sunrise AND sunset’ is essentially the same; tweets that contain both these words will be matched in any order.

The main reason you would want to use the AND operator is when stringing multiple operators together.

Combining Operators

For more complex Twitter searches, multiple operators can be used together to create a single search string.

Let’s say you wanted to search for design based jobs in London. Tweets advertising jobs might use numerous synonyms for the word ‘job’. To to help maximise tweets found, we could construct a search string using the AND and OR operators with variations on the word ‘job’, such as:

(London) AND (design OR designer OR creative) AND (career OR job OR jobs OR vacancy OR vacancies OR role)

The above query will find all tweets that mention ‘London’ along with any one of three variations on job title and any one of five variations of the word ‘job’.

Using a Social Bearing search with the above string returns over 500 tweets within the past 24 hours. When compared against a search for design jobs London which gets less than 100 tweets in a similar timeframe, it’s easy to see how useful complex search queries can be.

The use of brackets are also important as they allow multiple words and operator rules to be grouped together.

Within any regular search, a maximum limit of 500 characters can be allowed in a search string, after the string is URL encoded (for example a space will take up 3 characters when encoded as ‘%20’ in the URL).

Exclude keywords from tweet search

The hyphen “-” is equivalent to the boolean NOT operator. Using a hyphen with a keyword will exclude tweets containing that word (or hashtag etc) from the search results.

For example, the search
easter -egg -eggs

Will find tweets containing ‘easter’ but not ‘egg’ or ‘eggs’.

Find tweets from any language

When searching for tweets, you can select from 62 popular languages supported by Twitter using either the language drop down in the Social Bearing advanced Twitter search form or by using the lang: operator in the search field followed by the 2 letter language ISO code.

For example lang:de would search for German tweets.

The lang: command can be used by itself without any keywords, or combined with a regular search term and other operators.

Read more about finding tweets in a certain language

Find tweets from a specific handle

If you want to find any tweets for a given handle only, including regular tweets, retweets and replies then the from: command will be useful for this.

from: search is essentially the same as a user timeline search with the 7 day limit applied, so it is only really useful when used alongside other search commands to narrow down a twitter search.

For example
from:snowden apple

Will find all tweets mentioning ‘apple’ from @snowden handle

from:handle can be used in a search by itself or combined with any other commands or operators.

Find tweets to a specific user

The to: command in a Twitter search will find all direct tweets or replies from any handle to a specific handle. It does not include mentions of handle; to find mentions, a regular search of the @handle would do this.

You can use to: by itself or with other combinations. Using to: with from: can be useful to search for communications between two users.

You can also used to: and from: for the same Twitter user. This might be useful when you want to see replies a user has made to their own tweets.

Searching for tweets between dates

The commands since: and until: can be used to find tweets between two dates. On the Social Bearing advanced search form you can use the drop down’s, otherwise you’ll need to enter dates in the format since:yyyy-mm-dd or until:yyyy-mm-dd in the search field.

As with most Twitter tools, tweets are limited to the past 7 days using Twitter’s free API. Some tools such may go back further but these are usually paid services that make use of enterprise level historical platforms such as GNIP

Date based searches will take into account the retweet date to determine if retweets should be displayed, rather than the date the original retweeted tweet was created

The until date will not include the chosen date and will work up until that date. So if you select an until date of 2016-03-02, that should include all tweets up until midnight 2016-03-01

Selecting a since: and until: date with the same values therefore will return empty result. since: includes the selected date and beyond whereas until: includes everything before

Find tweets with pictures, videos or links

The filter: command using ‘media’, ‘videos’ or ‘links’ can be used in a search to find tweets containing media of these types. Alternatively, you can use the media options in the advanced search form

Tweets containing photos
The phrase sunset filter:media will find all tweets with images or videos. There is no ‘photo’ only based tweet command that can be used in a search, however you can still filter media types and select only pictures from the Social Bearing search filters on the results page

Find tweets containing videos
The filter:videos command is used to find tweets containing videos only. This will search for any tweets that have had videos uploaded directly to Twitter, or tweets containing links to popular video sites such as YouTube, Vine or Vimeo

Search for tweets with links
Tweets with any kind of link can be searched for using filter:links. Link filters also include pictures and other media as these are attached as a link to a tweet e.g. pic.twitter.com/vbas43asd

To further refine tweets with website links only, in the resulting Social Bearing search, you can select the ‘Links’ tweet type filter which don’t count picture based links

Find positive or negative tweets

You can use basic emoticons 🙂 or 🙁 within a regular search to find tweets with a generally positive or negative sentiment

For example, the search spring 🙂 will likely contain positive tweets about Spring and spring 🙁 will more likely be negative. This kind of search however doesn’t analyse the language used to determine sentiment; it will only match tweets containing positive or negative emoticons

Variations of these emoticons though are also taken into account. For example, a positive search using 🙂 will also return tweets containing 🙂 and 😀 which are all positive variations of the smiley

The smileys can be used independently in a search or combined with keywords and other operators

A basic sentiment search using Twitter operators is different from how Social Bearing calculates sentiment, which assigns sentiment based on the words used within tweets

Further Information

Examples of additional operators and examples that can be used in a Twitter Search can be found on Twitter’s search API page



Leave a Reply

Your email address will not be published. Required fields are marked *

css.php