Designing Secure Flutter Firestore Search QueriesDesigning Secure Flutter Firestore Search Queries
The network for creativity
Join 1.25M professional creatives like you
Connect with clients, get discovered, and run your business 100% commission-free
Creatives on Contra have earned over $150M and we are just getting started
A Flutter search box that downloads a collection and filters it in Dart pays for every document it filtered. For a 5,000-product catalog on a Standard edition database that is at least 5,000 document reads per load without a cache, and any draft the query could read now sits on a phone whose user was never meant to browse it. The backend follows from what people type. An order code is an equality query. The first letters of a name are a range query on a normalized field with a hard limit. Words anywhere need a text index: Firestore's own search on an Enterprise edition database, or an external service fed from Firestore. Two details decide whether it holds. Normalize the stored field and the typed term with one function, because a range query compares UTF-8 bytes and treats Č and c as unrelated. And read the real document before you show a hit, so Security Rules can refuse a draft or deleted item the index still lists. https://www.duskolicanin.com/blog/flutter-firestore-search-query-boundaries
Post image
Rafee 's avatar
The point about Č and c being unrelated in a range query is the kind of thing that bites you in production. Good reminder to normalize both sides.
Back to feed
The network for creativity
Join 1.25M professional creatives like you
Connect with clients, get discovered, and run your business 100% commission-free
Creatives on Contra have earned over $150M and we are just getting started