Twitter search handles billions of tweets:
Indexing: Inverted index built in near real-time. New tweets searchable within seconds.
Ranking factors:
- Recency (newer tweets rank higher)
- Engagement (likes, retweets)
- User authority (verified, follower count)
- Relevance (text match quality)
Challenges:
- Scale: Billions of documents
- Speed: Results in milliseconds
- Freshness: Index updates in seconds
Architecture: Sharded Elasticsearch or custom solution. Replicate for read throughput. Separate real-time and historical indexes.