How do you full text search an Amazon S3 bucket?
System Design practice on Codemia
Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.
Introduction
Amazon S3 is object storage, not a search engine. You can list objects by key prefix and query some structured data patterns with other AWS tools, but you cannot point a full-text query at a bucket and expect S3 itself to index document contents.
What S3 Can and Cannot Do
S3 stores objects and metadata. It can help you retrieve objects efficiently if you already know the key, prefix, or surrounding workflow. What it does not do natively is tokenize text, build inverted indexes, rank search results, or extract content from PDFs, Word documents, or HTML files.
So the real answer to "How do I full-text search an S3 bucket?" is:
- extract text from the objects
- index that text somewhere built for search
- query the index, not S3 directly
The Common AWS Architecture
The usual AWS design is:
- S3 stores the original files
- an event trigger detects new or changed objects
- a processor extracts text and metadata
- Amazon OpenSearch Service stores the searchable index
At a high level:
This keeps S3 in its natural role as durable storage while a search engine handles ranking and retrieval.
Example: Index Uploaded Text Files into OpenSearch
For plain text files, a Lambda function can read the object and push it into OpenSearch. A simplified example:
This is enough for text files. For PDFs or Office documents, add a text-extraction step before indexing.
What to Use for Non-Text Documents
Many S3 buckets store binary documents rather than raw text. In those cases, you need content extraction first. Common approaches include:
- AWS Lambda with a library that parses PDFs or Office formats
- AWS Textract for scanned or image-heavy documents
- a containerized batch job for large or complex documents
Once text is extracted, index the result along with useful metadata such as object key, upload time, tags, customer ID, or document type.
What About Athena or S3 Select?
These tools are useful, but they are not substitutes for full-text search.
- Amazon Athena is good for SQL over structured data stored in S3, such as JSON, CSV, or Parquet.
- S3 Select can retrieve subsets of structured object content.
Neither one is a general relevance-ranked document search engine. If your data is logs, tables, or newline-delimited JSON, Athena may be enough. If your requirement is "search all words inside uploaded documents," use an index built for that purpose.
A Search Query Example
Once data is in OpenSearch, querying becomes straightforward:
Now the search is running against indexed document content, not against S3 object storage.
Operational Considerations
A production design usually needs more than raw indexing:
- re-index documents when objects are replaced
- delete index entries when S3 objects are deleted
- store ACL-related metadata if access control matters
- normalize text, language, and file encodings
- monitor indexing failures and dead-letter events
For large buckets, a one-time backfill job is also necessary so the index covers existing objects, not just new uploads.
Common Pitfalls
- Expecting S3 itself to support keyword search inside documents leads to the wrong architecture.
- Indexing only filenames or object keys is not full-text search.
- Ignoring document parsing means PDFs and Office files appear "missing" from search results.
- Using Athena for relevance-ranked text search usually results in a poor experience.
- Forgetting delete and update handling causes the search index to drift away from the bucket contents.
Summary
- S3 does not provide native full-text search over object contents.
- The standard solution is S3 for storage plus text extraction plus an index such as OpenSearch.
- Lambda works well for event-driven indexing of new uploads.
- Athena and S3 Select help with structured queries, not general document search.
- Build the search system around an external index, and treat S3 as the source of truth for the files.
Related reading
- How do you get kubectl to log in to an AWS EKS cluster?
- How do you install modules within sagemaker training jobs?
- How do you locally load model.tar.gz file from Sagemaker?
- How do you look at console.log output of the amazon lambda function
- How do you make an S3 object public via the aws Java SDK?
- How do you pass Authorization header through API Gateway to HTTP endpoint?
- How do you pass custom environment variable on Amazon Elastic Beanstalk AWS EBS?
- How do you put up a maintenance page for AWS when your instances are behind an ELB?

System Design Fundamentals
Build a strong foundation in designing scalable, reliable distributed systems.
View the courseTrack what you have practised
A free account saves your progress, solutions and study plan across every problem on Codemia.
System Design practice on Codemia
Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.