Advanced Search
The Advanced Search feature allows users to perform more complex queries to filter tweets according to various criteria such as date ranges, specific users, hashtags, and more. Below you will find detailed information on how to construct advanced search queries.
Exact Search
Search for tweets containing specific hashtags.
Syntax: "\"searchterm\"
Example:
curl -X POST http://localhost:8080/api/v1/data/twitter/tweets/recent \
-H "Content-Type: application/json" \
-d '{"query": "\"masa\", "count": 10}'
Hashtag Search
Search for tweets containing specific hashtags.
Syntax: #hashtag
Example:
curl -X POST http://localhost:8080/api/v1/data/twitter/tweets/recent \
-H "Content-Type: application/json" \
-d '{"query": "#MasaNode", "count": 10}'
Mention Search
Search for tweets mentioning a specific user.
Syntax: @username
Example:
curl -X POST http://localhost:8080/api/v1/data/twitter/tweets/recent \
-H "Content-Type: application/json" \
-d '{"query": "@getmasafi", "count": 10}'
From User Search
Search for tweets posted by a specific user.
Syntax: from:username
Example:
curl -X POST http://localhost:8080/api/v1/data/twitter/tweets/recent \
-H "Content-Type: application/json" \
-d '{"query": "from:getmasafi", "count": 10}'
To User Search
Search for tweets directed to a specific user.
Syntax: to:username
Example:
curl -X POST http://localhost:8080/api/v1/data/twitter/tweets/recent \
-H "Content-Type: application/json" \
-d '{"query": "to:getmasafi", "count": 10}'
Language-Specific Search
Search for tweets in a specific language.
Syntax: lang:language_code
Example:
curl -X POST http://localhost:8080/api/v1/data/twitter/tweets/recent \
-H "Content-Type: application/json" \
-d '{"query": "Masa lang:en", "count": 10}'
Date Range Search
Search for tweets within a specific date range.
Syntax: since:yyyy-mm-dd until:yyyy-mm-dd
Example:
curl -X POST http://localhost:8080/api/v1/data/twitter/tweets/recent \
-H "Content-Type: application/json" \
-d '{"query": "Masa since:2021-01-01 until:2021-12-31", "count": 10}'
Exclude retweets from your search results.
Syntax: -filter:retweets
Example:
curl -X POST http://localhost:8080/api/v1/data/twitter/tweets/recent \
-H "Content-Type: application/json" \
-d '{"query": "Masa -filter:retweets", "count": 10}'
Minimum Likes Filter
Search for tweets with a minimum number of likes.
Syntax: min_faves:number
Example:
curl -X POST http://localhost:8080/api/v1/data/twitter/tweets/recent \
-H "Content-Type: application/json" \
-d '{"query": "Masa min_faves:100", "count": 10}'
Search for tweets with a minimum number of retweets.
Syntax: min_retweets:number
Example:
curl -X POST http://localhost:8080/api/v1/data/twitter/tweets/recent \
-H "Content-Type: application/json" \
-d '{"query": "Masa min_retweets:50", "count": 10}'
Keyword Exclusion
Exclude tweets with certain keywords.
Syntax: -keyword
Example:
curl -X POST http://localhost:8080/api/v1/data/twitter/tweets/recent \
-H "Content-Type: application/json" \
-d '{"query": "Masa -moon", "count": 10}'
OR Operator
Combine multiple terms, where at least one must be present.
Syntax: term1 OR term2
Example:
curl -X POST http://localhost:8080/api/v1/data/twitter/tweets/recent \
-H "Content-Type: application/json" \
-d '{"query": "Masa OR Oracle", "count": 10}'
Geo-location Based Search
Search for tweets by users located within a certain radius of a given latitude and longitude.
Syntax: geocode:latitude,longitude,radius
Example:
curl -X POST http://localhost:8080/api/v1/data/twitter/tweets/recent \
-H "Content-Type: application/json" \
-d '{"query": "Masa geocode:37.781157,-122.398720,1mi", "count": 10}'
URL Inclusion Search
Search for tweets containing a specific URL.
Syntax: url:"http://example.com"
Example:
curl -X POST http://localhost:8080/api/v1/data/twitter/tweets/recent \
-H "Content-Type: application/json" \
-d '{"query": "url:\"http://example.com\"", "count": 10}'
Search for tweets asking a question.
Syntax: ?
Example:
curl -X POST http://localhost:8080/api/v1/data/twitter/tweets/recent \
-H "Content-Type: application/json" \
-d '{"query": "Masa ?", "count": 10}'
Safe Search Mode
Exclude adult content from your search results.
Syntax: filter:safe
Example:
curl -X POST http://localhost:8080/api/v1/data/twitter/tweets/recent \
-H "Content-Type: application/json" \
-d '{"query": "Masa filter:safe", "count": 10}'
Each of these search types can be combined to create more complex queries, allowing for highly targeted searches. Remember to test each example to ensure they work as expected and to provide users with accurate and helpful documentation.