Full Text Search with Firebase on Android using Algolia(Part 1)

Full Text Search with Firebase on Android using Algolia(Part 1)

Subscribe to my newsletter and never miss my upcoming articles

Most of the applications we develop show lists, which means that most of them support some kind of search functionality. The data to be displayed can be from a backend service such as Firebase Firestore. Firebase is a great tool to quickly and easily give backend functionality to your application although it has a major downside. It does not support Full-Text search.

What is Full-Text search? (for dummies)

This is an exhaustive search method that looks for occurrences of the search term in the entire document or database. This means that the user can find a word or a phrase as long as it occurs anywhere in the database or document.

Once the user initiates a search request, the pages are searched and then indexed. Any matches are presented to the user via the indexes. Normally, the result is presented in such a way that the original text in the database or document is shown together with the user’s query term.

To explain the above point easily, consider the following text in a database.

Once the user initiates a search request, the pages are searched and then indexed. Any matches are presented to the user via the indexes. Normally, the result is presented in such a way that the original text in the database or document is shown together with the user’s query term.</span>

Say you search for the word database, the result may look like the following.

the original text in the **database** or document is shown together</span>

The search term is usually in bold to improve the overall experience. This is the same technique that is used by some web search engines to provide the seamless experience that we have come to love and enjoy today.

Full-Text Search on Firebase

Firebase does not support this functionality out of the box. To support such functionality, the Firebase team suggests the use of third-party tools such as Algolia. Indeed, that is the focus of this series. We will examine the following things:

  1. How to import data into Algolia. This applies to those projects that already have a database but do not support full-text search.
  2. How to search for data in an Android application.
  3. How to listen to changes in your database such that any changes in your database also updates your data in Algolia.

This is by no means a beginner tutorial. To work with this effectively, you should have a basic understanding of JavaScript. You should also be comfortable using Android Jetpack components.

Until next time!

PS: Let us connect on GitHub, Twitter, and LinkedIn.

 
Share this