Search code examples
twitterphirehose

How to track and stream tweets for keywords with AND operator using phirehose library?


I am trying to connect to streaming API of twitter and retrieve tweets keywords using specific keywords. I am using the phirehose library for the same. It says in the twitter documentation that "commas as logical ORs, while spaces are equivalent to logical ANDs (e.g. ‘the twitter’ is the AND twitter, and ‘the,twitter’ is the OR twitter)."

But I want to search for keywords with AND operator even if there are other words in between. Meaning if we want to search for tweets having Keyword1 AND Keyword2, tweets which have only one keyword should not be retrieved.

Using the settrack function of the phirehose library -

setTrack(array('the , twitter'));

retrieves tweets with either the OR twitter while

setTrack(array('the twitter'));

retrieves tweets with the phrase the twitter and does not retrieve tweets like the busy twitter for example.

Please help.


Solution

  • 140dev by Adam Green gives a solution for this by using ``typeenum('words','phrase') NOT NULL DEFAULT 'words'

    Please see - http://140dev.com/twitter-api-programming-blog/streaming-api-enhancements-part-2-keyword-collection-database-changes/ and

    http://140dev.com/twitter-api-programming-blog/streaming-api-enhancements-part-3-collecting-tweets-based-on-table-of-keywords/