Posted by Dan Saadati, Software Engineer, and Hanaa ElAzizi, Technical Program Manager
Introducing AppSearch in Jetpack, now available in Alpha. Searching for applications is an on-device search library that provides high-performance, feature-rich full-text search capabilities.
With AppSearch, your app can:
- To offer offline search capabilities because AppSearch data lives entirely on the device.
- To have lower latency for indexing and querying on large datasets compared to SQLite, due to lower I / O usage.
- To bring relevant research results with built-in scoring strategies, such as BM25F.
- To bring multilingual support for text search.
- Issue a single query to retrieve data of multiple datatypes versus a query by datatype 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 example, you can model a message as a schema type with properties such as subject, body, and sender.
Documents added to your database can be queried. Searching for “body: fruit” will retrieve all documents containing the term “fruit” in the “body” of the message.
Diagram showing indexing and searching in AppSearch
To show how an app can integrate AppSearch, let’s take this sample shopping list app. Users can add grocery items to their list for reference when shopping. Because AppSearch offers multilingual support by default, users can also include specialty ingredients for their overall recipes. Users add an item by entering the name and selecting the store and category to which it belongs. User can search by item name and select filters for store or category. AppSearch will return matching results for the app to display.
Help us improve the library: Give us feedback on things you like, issues or features you would like to see. If you find any bug or problem, please feel free to file a problem.