Android Developers Blog
The latest Android and Google Play news for app and game developers.
🔍
Platform Android Studio Google Play Jetpack Kotlin Docs News

14 junio 2021

Build sophisticated search features with AppSearch


Link copied to clipboard

Posted by Dan Saadati, Software Engineer, and Hanaa ElAzizi, Technical Program Manager

Introducing AppSearch in Jetpack, now available in Alpha. AppSearch is an on-device search library which provides high performance and feature-rich full-text search functionality.

With AppSearch, your application can:

  • Offer offline search capabilities as AppSearch data lives completely on-device.
  • Have lower latency for indexing and querying over large data sets compared to SQLite, due to lower I/O use.
  • Provide relevant search results with built-in scoring strategies, such as BM25F.
  • Provide multi-language support for text search.
  • Issue a single query to retrieve data of multiple data types compared to issuing one query per data type in SQLite.

In AppSearch, you need to create a database to manage structured data, called “documents”. You then define what the structure looks like using “schema types”. For instance, you can model a message as a schema type with properties such as subject, body, and sender.

Documents that are added to your database can be queried over. Querying for “body:fruit” will retrieve all documents with the term “fruit” in the “body” of the Message.

Diagram illustrating indexing and searching within AppSearch

Diagram illustrating indexing and searching within AppSearch

To showcase how an application might integrate AppSearch, take this example of a grocery list application. Users can add grocery items to their list to refer to when they’re out shopping. Since AppSearch offers multi-language support by default, users can also include specialty ingredients for their global recipes. Users add an item by typing in the name and selecting the store and category it belongs to. The user can search by item name and select filters for store or category. AppSearch will return matching results for the application to display.

Ready to dive into using AppSearch to enrich your app’s search functionality? Check out the AppSearch guide and start using it in your app.

Help us make the library better: give us feedback on things you like, and issues or features you would like to see. If you find a bug or issue, feel free to file an issue.