Class TwitterSearchReader
java.lang.Object
com.northconcepts.datapipeline.core.DataObject
com.northconcepts.datapipeline.core.Endpoint
com.northconcepts.datapipeline.core.DataEndpoint
com.northconcepts.datapipeline.core.DataReader
com.northconcepts.datapipeline.internal.lang.IntegrationReader
com.northconcepts.datapipeline.twitter.TwitterReader
com.northconcepts.datapipeline.twitter.TwitterSearchReader
Obtains records by searching Twitter for the most recent tweets matching a search criteria.
This reader uses the Twitter Search API and supports all Query Operators.
Example of record returned:
Record {
0:[Id]:LONG=[509084459472551936]:Long
1:[Text]:STRING=[+ @Squarespace invalid input: '&' @Shutterstock MT @NewYork_CM: #TY again @Freshbooks invalid input: '&' @MailChimp for #CreativeMornings! https://t.co/aW7cdAMyYW...140]:String
2:[Lang]:STRING=[en]:String
3:[CreatedAt]:DATETIME=[Mon Sep 08 17:02:48 EDT 2014]:Date
4:[FavoriteCount]:INT=[1]:Integer
5:[RetweetCount]:INT=[0]:Integer
6:[InReplyToScreenName]:STRING=[NewYork_CM]:String
7:[UserScreenName]:STRING=[mitgc_cm]:String
8:[UserDescription]:STRING=[#Socbiz strat + #Lean venture dev | @Plus_SocialGood Connector | #socent #impinv #sustdev | @StartingBloc #SocInn | NY exec prod...157]:String
9:[UserCreatedAt]:DATETIME=[Mon Nov 28 21:09:22 EST 2011]:Date
10:[UserTweets]:INT=[42485]:Integer
11:[UserFavouritesCount]:INT=[13329]:Integer
12:[UserFollowersCount]:INT=[6598]:Integer
13:[UserFollowingCount]:INT=[6912]:Integer
14:[UserLocation]:STRING=[New York, New York, USA]:String
15:[UserLang]:STRING=[en]:String
16:[UserTimeZone]:STRING=[London]:String
17:[UserUtcOffset]:INT=[3600]:Integer
18:[UserURL]:STRING=[http://t.co/D8ykYnFD3I]:String
19:[GeoLocationLatitude]:DOUBLE=[40.7450718]:Double
20:[GeoLocationLongitude]:DOUBLE=[-73.9964114]:Double
21:[PlaceName]:STRING=[Manhattan]:String
22:[PlaceFullName]:STRING=[Manhattan, NY]:String
23:[PlaceType]:STRING=[city]:String
24:[PlaceStreetAddress]:UNDEFINED=[null]
25:[PlaceCountryCode]:STRING=[US]:String
26:[PlaceCountry]:STRING=[United States]:String
27:[PlaceBoundingBoxType]:STRING=[Polygon]:String
28:[PlaceBoundingBoxCoordinates]:STRING=[[[40.683935,-74.026675],[40.683935,-73.910408],[40.877483,-73.910408],[40.877483,-74.026675]]]:String
29:[UserMentionEntities]:STRING=[@Squarespace @Shutterstock @NewYork_CM @freshbooks @MailChimp @mitgc_cm]:String
30:[HashtagEntities]:STRING=[#TY #CreativeMornings]:String
31:[URLEntities]:STRING=[https://pbs.twimg.com/media/BwxyTHtIQAAKDUz.jpg]:String
32:[MediaEntities]:UNDEFINED=[null]
}
-
Nested Class Summary
Nested classes/interfaces inherited from class com.northconcepts.datapipeline.core.DataEndpoint
DataEndpoint.State -
Field Summary
Fields inherited from class com.northconcepts.datapipeline.twitter.TwitterReader
EOFFields inherited from class com.northconcepts.datapipeline.core.DataReader
fieldLineage, recordLineageFields inherited from class com.northconcepts.datapipeline.core.DataEndpoint
lastRecord, PRODUCT, PRODUCT_VERSION, VENDOR, XML_INPUT_FACTORY_KEYFields inherited from class com.northconcepts.datapipeline.core.Endpoint
BUFFER_SIZE, captureElapsedTime, DEFAULT_READ_BUFFER_SIZEFields inherited from class com.northconcepts.datapipeline.core.DataObject
id, log, name, TIMESTAMP_FORMAT -
Constructor Summary
ConstructorsConstructorDescriptionTwitterSearchReader(TwitterProvider provider, String searchQuery, int maxResults) Creates a reader for tweets matchingsearchQuerythat stops aftermaxResultstweets.TwitterSearchReader(String consumerKey, String consumerSecret, String searchQuery, int maxResults) Creates a reader for tweets matchingsearchQuerythat stops aftermaxResultstweets.TwitterSearchReader(String consumerKey, String consumerSecret, String accessToken, String accessTokenSecret, String searchQuery, int maxResults) Creates a reader for tweets matchingsearchQuerythat stops aftermaxResultstweets. -
Method Summary
Modifier and TypeMethodDescriptionaddExceptionProperties(DataException exception) Adds this endpoint's current state to aDataException.voidclose()Indicates that this endpoint has finished reading or writing.longgetMaxId()Searches for tweets with IDs less than the specified ID (i.e.longSearches for tweets with IDs greater than the specified ID (i.e.voidopen()Makes this endpoint ready for reading or writing.protected RecordreadImpl()Overridden by subclasses to read the next record from thisDataReader.setApiLimitPolicy(IApiLimitPolicy apiLimitPolicy) Sets the action taken when the API call limit is reached (defaults toApiLimitPolicy.FAIL).setMaxId(long maxId) Searches for tweets with IDs less than the specified ID (i.e.setSinceId(long sinceId) Searches for tweets with IDs greater than the specified ID (i.e.Methods inherited from class com.northconcepts.datapipeline.twitter.TwitterReader
getApiLimitPolicy, getConverter, getEntityExpansionPolicy, getProvider, getRateLimit, getRateLimit, isRateLimitExceeded, onRateLimitExceeded, reloadRateLimit, setConverter, setEntityExpansionPolicy, setRateLimit, setRateLimit, setRateLimitExceededMethods inherited from class com.northconcepts.datapipeline.core.DataReader
addLineage, available, getBufferSize, getNestedEndpoint, getNestedReader, getReader, getRootEndpoint, getRootReader, isExhausted, isLineageSupported, isSaveLineage, peek, pop, push, read, setSaveLineage, skipMethods inherited from class com.northconcepts.datapipeline.core.DataEndpoint
decrementRecordCount, enableJmx, getLastRecord, getRecordCount, getRecordCountAsBigInteger, getRecordCountAsString, incrementRecordCount, isRecordCountBigInteger, resetRecordCount, toStringMethods inherited from class com.northconcepts.datapipeline.core.Endpoint
addElapsedtime, assertClosed, assertNotOpened, assertOpened, finalize, getClosedOn, getDescription, getElapsedTime, getElapsedTimeAsString, getOpenedOn, getOpenElapsedTime, getOpenElapsedTimeAsString, getSelfTime, getSelfTimeAsString, getState, isCaptureElapsedTime, isClosed, isOpen, setCaptureElapsedTime, setDescription
-
Constructor Details
-
TwitterSearchReader
Creates a reader for tweets matchingsearchQuerythat stops aftermaxResultstweets. -
TwitterSearchReader
public TwitterSearchReader(String consumerKey, String consumerSecret, String searchQuery, int maxResults) Creates a reader for tweets matchingsearchQuerythat stops aftermaxResultstweets. -
TwitterSearchReader
public TwitterSearchReader(String consumerKey, String consumerSecret, String accessToken, String accessTokenSecret, String searchQuery, int maxResults) Creates a reader for tweets matchingsearchQuerythat stops aftermaxResultstweets.
-
-
Method Details
-
getMaxId
public long getMaxId()Searches for tweets with IDs less than the specified ID (i.e. tweets created earlier) or -1 for all tweets (default-1). -
setMaxId
Searches for tweets with IDs less than the specified ID (i.e. tweets created earlier) or -1 for all tweets (default-1). -
getSinceId
public long getSinceId()Searches for tweets with IDs greater than the specified ID (i.e. tweets created later) or -1 for all tweets (default-1). -
setSinceId
Searches for tweets with IDs greater than the specified ID (i.e. tweets created later) or -1 for all tweets (default-1). -
open
Description copied from class:DataEndpointMakes this endpoint ready for reading or writing.- Overrides:
openin classTwitterReader- Throws:
DataException
-
close
Description copied from class:DataEndpointIndicates that this endpoint has finished reading or writing.- Overrides:
closein classDataEndpoint- Throws:
DataException
-
setApiLimitPolicy
Description copied from class:TwitterReaderSets the action taken when the API call limit is reached (defaults toApiLimitPolicy.FAIL).- Overrides:
setApiLimitPolicyin classTwitterReader
-
readImpl
Description copied from class:DataReaderOverridden by subclasses to read the next record from thisDataReader. The default implementation ofDataReader.read()now insures that this method will not be called again after it returns anull.If no record is available,
nullwill be returned.Contract for subclasses (see also
docs/authoring/DataReader.md):- Return
nullexactly once to signal end-of-stream. - Do not call this method directly —
DataReader.read()is the template method that wraps exceptions, increments the record count, and tracks lineage. - Do not call
DataEndpoint.incrementRecordCount()here;DataReader.read()already does. - Throw raw exceptions;
DataReader.read()wraps them viaexception(throwable).
- Specified by:
readImplin classDataReader- Throws:
Throwable
- Return
-
addExceptionProperties
Description copied from class:EndpointAdds this endpoint's current state to aDataException. Since this method is called whenever an exception is thrown, subclasses should override it to add their specific information.- Overrides:
addExceptionPropertiesin classTwitterReader
-