Firebase App Indexing for Personal Content— Getting Personal Content into Search

Bob
AndroidPub
Published in
3 min readNov 26, 2016
Image Source: scotch.io

Search is an essential aspect in mobile apps. Search is a better alternative to manually navigating into deep hierarchically structured apps. Some apps even have Global Search, to search all the data in all the possible modules in the app from a single search box. The next step is to let the user search all the data in all the apps installed in the device from a single search box — from the “One search box” that we always have at the top of our device home screen.

Demo shows search in apps and opens the Recipe App directly from search. App Source and Gif conversion tool.

App Indexing API for the public content like Medium, Quora, Youtube — has been available for more than a year. Previously, App indexing required the content to be uploaded to Google servers and obviously it was not suitable for the user personal content. In the recent version 10.0, Firebase App Indexing API adds support for Google on-device index without the need for Google servers, to make the personal content searchable in the device.

In September, Google released this feature to only a few apps like Spotify, Facebook Messenger, Evernote, Todoist, Gmail, Google Keep, Asana. Few days before, Google made this API public that lets all the developers add content from their apps to Google’s on-device index.

Searching your personal results happens entirely on your phone, so you can search even when you’re not connected to WiFi or cellular data.

In future, we might get a dedicated shortcut on the home screen to search in apps.

Dedicated shortcut on the home screen to search in apps. Gif source.

Advantages are obvious:

  • Better user experience. Consider Google Keep. The traditional way to open a to-do list would be like opening the app drawer > scroll and find the Google Keep > find the to-do list > open the list. Using the App Indexing, it is just a tap on the search on the home screen and type to find the to-do list.
  • Implementing the new features or APIs as soon it is released by Google makes it more likely for the apps to get featured in Play store, which improves the app visibility and user installs.

Privacy Concerns (Quoting from Firebase Site):

A note about privacy: The personal content index only exists on the user’s device. None of the user’s personal content is uploaded to Google servers and it only remains on the device while the app is installed.

However, aggregated statistics about apps’ usage of App Indexing and other system health information may be uploaded to Google servers.

How to implement:

Check out this implementation guide and codelab for detailed steps and the necessary code. At a high level, it requires just the following 4 steps.

  1. Create a new project in the Firebase console and get the google-services.json file using the application package name. Add that file into the app/ directory in the project.
  2. Add necessary dependency and plugin details in build.gradle
  3. Add AppIndexingService class, which is a subclass of IntentService, and write code to add the personal content to Google index periodically
  4. Write few lines of code to add the content to Google index when the user adds or updates a record and code to remove the content from Google index when the user deletes a record.

Looks so simple, isn’t it? It took me just less than 2 hours to set this up and running in our application. But it might take some more time to think and solve all the necessary application dependent use-cases.

If you liked this, click the 💚 below, and don’t forget to share your thoughts in the comments.

--

--