Photo by John Cameron on Unsplash

Picture this: You’re using a mobile app, trying to find crucial information, but each search query feels like an eternity. Frustration mounts as precious seconds tick away. If you’ve ever experienced this, you’re not alone. Slow search functionality can be a death sentence for user satisfaction in today’s fast-paced digital world.

I too faced this dilemma, with search times in my app soaring to a frustrating 10 seconds. However, I didn’t settle for sluggish search results. In this article, I will take you on a journey into the world of lightning-fast mobile searches. I’ll present to you a powerful technique called Full Text Search (FTS), armed with the formidable tools of SQLDelight and Kotlin Multiplatform.

Search in Mobile Apps

Search functionality is non-negotiable, users demand lightning-fast, intuitive and accurate search experiences, and the success of your app often depends on delivering just that.

In big complex apps with lots of data, this can be quite a challenge. That’s where FTS comes to the rescue solving this problem whether your app is offline first or switches to a local database when there’s no connection.

Quick overview on KMP and SQLDelight

Kotlin Multiplatform (KMP) is a technology that allows us to share code between iOS and Android apps (among other platforms), its initial goal was to share only business logic, but now we have Compose Multiplatform which lets us share UI code too.

I wrote an article proposing an architecture for KMP sharing ViewModels, check it out here.

On the other hand, SQLDelight is just a plugin that generates Kotlin APIs from SQL statements, with SQLDelight we can easily create tables and define queries using SQLite and get some Kotlin classes and functions to access them for free.

Is it magic? How it works?

There’s no magic here; it’s all about very clever indexing. FTS relies on creating highly efficient indexes over the columns we specify. These indexes are like well-organized reference books that make searching…

Source link