Query limitations
Your queries will be limited depending on which access level you are using:| Access level | Recent search | Full-archive search |
|---|---|---|
| Self-serve | 512 characters | 1,024 characters |
| Enterprise | 4,096 characters | 4,096 characters |
Operator availability
While most operators are available to any developer, some are reserved for certain access levels:- Core operators: Available when using any Project
- Advanced operators: Available when using a Project with certain access levels
Operator types: standalone and conjunction-required
Standalone operators can be used alone or together with any other operators (including those that require conjunction). For example, this query works because#hashtag is a standalone operator:
"X data", the query works properly:
Boolean operators and grouping
String together multiple operators using these tools:| Operator | Description | Example |
|---|---|---|
| AND (space) | Posts must match both conditions | snow day #NoSchool matches Posts with “snow” AND “day” AND #NoSchool |
| OR | Posts must match either condition | grumpy OR cat OR #meme matches Posts with “grumpy” OR “cat” OR #meme |
| NOT (dash) | Exclude Posts matching this condition | cat #meme -grumpy matches Posts with “cat” and #meme but NOT “grumpy” |
| Grouping (parentheses) | Group operators together | (grumpy cat) OR (#meme has:images) matches either group |
A note on negations
- The operator
-is:nullcastmust always be negated - Negated operators cannot be used alone
- Do not negate grouped operators. Instead of
skiing -(snow OR day OR noschool), useskiing -snow -day -noschool
Order of operations
When combining AND and OR:- Operators connected by AND logic are combined first
- Then, operators connected with OR logic are applied
| Query | Evaluated as |
|---|---|
apple OR iphone ipad | apple OR (iphone ipad) |
ipad iphone OR android | (iphone ipad) OR android |
Punctuation, diacritics, and case sensitivity
Diacritics: Search queries with accents or diacritics match Posts both with and without the accents. For example,Diacrítica matches both Diacrítica and Diacritica.
Case sensitivity: All operators are case-insensitive. The query cat matches cat, CAT, and Cat.
Filtered stream behaves differentlyWhen building filtered stream rules, keywords with accents only match Posts that also include the accent. For example,
Diacrítica only matches Diacrítica, not Diacritica.Quote Tweet matching
When using Search Posts, operators match on the Quote Tweet’s content but not on the content from the original Post that was quoted.Filtered stream behaves differently—it matches on both the Quote Tweet and the original Post’s content.
Specificity and efficiency
Tips for building effective queries:- Start specific, then broaden — Create targeted queries that return relevant results
- Use multiple operators — Combine operators to narrow results
- Watch your character count — The entire query string counts toward the limit
Iteratively building a query
Step 1: Start with a basic query
Step 2: Test and narrow based on results
We noticed Posts in many languages. Add a language filter:Step 3: Broaden for better coverage
We want to capture more sentiment. Add related keywords:Step 4: Adjust for trends
Holiday Posts are appearing. Exclude them:Adding a query to your request
Use thequery parameter and HTTP encode your query:
Query examples
Tracking a natural disaster
Match Posts from weather agencies about Hurricane Harvey: Query:Sentiment analysis for #nowplaying
Positive sentiment:Using Post annotations
Find Japanese Posts about pets (not cats) with images using thecontext: operator:
First, use Post lookup with tweet.fields=context_annotations to identify domain.entity IDs:
- Cats:
domain66,entity852262932607926273 - Pets:
domain65,entity852262932607926273
Tools
Query Builder Tool
Build and test your queries interactively