Implementing AI Address Autocomplete with Partial Input in Mobile Apps
User types "Lenin 1"—app should guess: Lenin 12 in their city, or Lenin street in neighboring district they visit often, or address entered last week. Standard Google Places Autocomplete without context gives long list from entire country. AI autocomplete ranks differently—considering geolocation, history, input patterns.
AI Autocomplete vs. Standard
Classic autocomplete (Google Places API / Dadata / Nominatim): query "Lenin 1" → full-text search in database → top results by string relevance.
AI approach adds three layers:
Geo-context. Current user position (or last known) applied as location bias. Google Places API supports locationBias natively. For custom model—multiply each candidate score by exp(-distance_km / decay_radius), where decay_radius is 5-10 km for urban addresses.
Personal history. Addresses from past orders/searches stored locally (SQLite, encrypted) and in profile. On partial input—first match history, then external API. "Home", "work" matches—output without external request. Privacy-important.
Fuzzy search / typos. "Lenin" vs "Leninya", "pr-t" vs "prospect" vs "prosp". Normalization: expand abbreviations through dictionary (st. → street, pr-kt → prospect), apply Levenshtein distance threshold 2. For Cyrillic: additionally transliteration and Cyrillic Soundex analog.
Geoding API Selection
| Provider | Strengths | Free Limit |
|---|---|---|
| Google Places Autocomplete | Quality, coverage | $200 credit/month |
| Dadata | Russia/CIS, entrances, KLADR | 10,000 req/day |
| Yandex Geocoder | Russia/CIS, better regions | 1,000 req/day |
| Nominatim (OSM) | Free, self-host | 1 req/sec public |
| Pelias (self-hosted) | Full control, GDPR | — |
For Russia/CIS audience: Dadata + Redis cache = optimal price/quality. For international—Google Places with locationBias.
Mobile Implementation
Request Debounce
Request on every keystroke—too often. Debounce 300-400ms: timer resets on each character, request sent only after pause.
iOS (Combine): Publisher on UITextField.textPublisher → .debounce(for: .milliseconds(350), scheduler: RunLoop.main) → .removeDuplicates() → flatMap { autocomplete(query: $0) }.
Android (Kotlin Flow): MutableStateFlow on TextFieldValue → .debounce(350) → .distinctUntilChanged() → flatMapLatest { fetchAutocomplete(it) }.
Minimum query length: 2-3 characters. Less—results useless and wasted traffic.
Client Cache
NSCache / LruCache keyed by normalized query string. TTL 10 minutes. On similar re-entry (backspace + different letter)—first check cache of adjacent queries via prefix-match.
Offline Fallback
For apps needing address without internet (delivery, taxi in poor coverage): SQLite database with city addresses (FIAS for Russia—free, ~2-5 GB compressed, can preload needed regions). Search via FTS5 MATCH—fast even on mobile.
Confirmation via Geocoder
After user selects address—reverse geocoding for confirmation: pass selected address, get back lat/lon + normalized address in standard format. Show on map—marker at selected point. If wrong location—user sees immediately.
Localization and Formats
Russia addresses: "street", "avenue", "lane", "highway" + number, building, structure, apartment. Dadata returns structured KLADR object—parse into form automatically. Google returns address_components[]—parse similarly.
Ukrainian/Belarusian street spelling support (CIS audience): transliteration dictionary + Dadata supports UA as separate base.
Timeline
Implement AI address autocomplete with history, geo-bias, fuzzy search—1-3 days with chosen data provider. With offline FIAS base and custom ranking model—1-2 weeks. Cost estimated after requirement analysis.







