While searching twitter for rather generic terms, returned search results include bio-names and handles of users. How to filter those fields from search results?

For example: Searching latest tweets containing word 'Squawk' mostly returns usernames+handles containing the word 'Squawk' or mentioning/replying to such usernames+handles.



I’m hitting this same problem and I don’t believe there’s a complete solution using Twitter search features. There are several incomplete workarounds you can try, though.

First, you can add negative search terms for any usernames that appear in the results, e.g. Squawk -LiveSquawk -IGSquawk etc. to ignore specific users containing Squawk in their handle. Note that you have to use the bare username without including the @ symbol to handle the most common issues. This means the method only works if you’re willing to exclude any results containing superstrings of the excluded users. For example, if there’s prolific/popular user @squawking that you wish to filter out, searching for squawk -squawking will exclude tweets containing squawking in normal English usage as well.

This first method obviously doesn’t work if the problem user’s name is exactly your query. In this case you can get a more complete solution by listing out the different contingencies you want to ignore. For example, the following query will find instances of the string kimkardashian that are not written by @KimKardashian, not replies to or mentions of @KimKardashian, and do not use the hashtag #KimKardashian: “kimkardashian” -from:kimkardashian -to:kimkardashian -@KimKardashian -#KimKardashian. (Of course, this causes your query to explode in length if multiple popular users are causing problems.)

In the worst case, if your search query is a very common substring of many usernames, I don’t believe there’s any solution. For example, searching for tweets whose tweet body contains the string Mike, but without including all tweets from the many, many users with “Mike” in their usernames, seems to be impossible without applying the filtering yourself externally.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.