Fulltext Search DynamoDB
System Design practice on Codemia
Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.
Introduction
DynamoDB is excellent for key-based access patterns, but it is not a full-text search engine. If you need stemming, relevance ranking, typo tolerance, or multi-field text queries, the usual answer is to keep DynamoDB as the source of truth and index searchable text somewhere else.
Why DynamoDB alone is not enough
DynamoDB can query efficiently by partition key, sort key, and secondary indexes. What it cannot do well is "find all items whose description contains related forms of this phrase and rank them by relevance." A contains filter is not full-text search. It scans data, does not tokenize text, and does not scale well for search-heavy workloads.
That distinction matters because many teams start by trying to force search into DynamoDB, then discover that the table design gets worse while search quality stays poor.
Common architecture: DynamoDB plus OpenSearch
The standard AWS design is:
- write canonical records to DynamoDB
- capture table changes with DynamoDB Streams
- push searchable fields into Amazon OpenSearch Service
- query OpenSearch for search results
- optionally hydrate results from DynamoDB if you need the latest full record
This keeps transactional writes simple while giving search its own index and ranking rules.
Indexing DynamoDB changes into OpenSearch
The Lambda below handles DynamoDB Stream events and updates an OpenSearch index. It uses boto3 for AWS credentials and opensearch-py for indexing.
This pattern gives near-real-time indexing without changing your application write path.
Querying the search index
Once the index exists, search becomes much closer to what users expect:
This can search across multiple fields and boost title matches above body matches. That is the kind of relevance behavior DynamoDB does not provide natively.
Alternatives and tradeoffs
OpenSearch is the default answer, but not the only one:
- Algolia if you want a managed search product with less infrastructure work
- Meilisearch or Typesense if you control your own search service
- application-side filtering only when the dataset is small and search quality is not important
The right choice depends on scale and operational appetite. The core idea stays the same: the transactional store and the search index serve different purposes.
Common Pitfalls
- Using DynamoDB
ScanplusFilterExpressionand calling it full-text search. It is not. - Indexing every attribute instead of only the fields users actually search.
- Forgetting delete handling, which leaves stale documents in the search index.
- Assuming OpenSearch is strongly consistent with DynamoDB. There is usually indexing lag.
- Returning search hits directly when the application really needs to re-read authoritative data from DynamoDB.
Summary
- DynamoDB is a great key-value and document store, but it does not provide true full-text search.
- The common production pattern is DynamoDB plus Streams, Lambda, and OpenSearch.
- Use DynamoDB as the source of truth and keep only searchable fields in the search index.
- Expect eventual consistency between the table and the search engine.
- Pick a dedicated search system when you need ranking, stemming, phrase matching, or typo tolerance.
Related reading
- Function not found after manually deleting a function in a SAM CloudFormation stack
- Function to scan AWS Dynamo DB recursively for Nodejs
- GAE-ready asynchronous operations in Python?
- GCE VM can't connect to TPU
- Fulltext Search with InnoDB
- Function vs. Stored Procedure in SQL Server
- GCM with PHP Google Cloud Messaging
- GCP Bigtable Availability within a zone

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.