Firebase Full-Text Search, In Minutes (2023)

Firebase is known for its simplicity and ease of use, but it lacks one crucial feature―full-text search, being able to search for keywords in documents.

Full-text search is key for many websites and apps to go through large amounts of text. Rolling out your own search engine is both complex and time-consuming, so the lack of full-text search in Firebase is an important pain point for modern web projects.

In this article, we'll learn about using Rowy as a low-code CMS for Firebase data with a built-in full-text search feature right from a simple-to-use spreadsheet UI. We'll be combining Rowy with MeiliSearch to handle many documents without having to worry about maintaining search indexes manually.

1. Getting Started

First, we need to connect Rowy to MeiliSearch. MeiliSearch is a search engine API you can add to any app.

It only takes a couples of minutes to get started:

  1. Subscribe to Rowy's Pro plan - Full-text search is a premium feature that's only available in the Pro plan.
  2. Create a MeiliSearch account - Go to the MeiliSearch Developer Portal and sign up for free. The free tier includes 10K searches per month.
  3. Create a new project - Enter a unique project name, select a region, a MeiliSearch version, and select the free plan.
  4. Obtain accesses - You'll need a Search Instance URL and a Master Key to call the MeiliSearch API.
  5. Configure Rowy - In Rowy's Project Settings section under the Services tab, paste the Search Instance URL and the Master Key. Then, click on Enable to activate the full text search feature in your project.
  6. Enable searchable tables - Lastly, enable the tables you want to search by clicking on the corresponding toggle buttons in the Table Settings of your project.

You're set! Now, let's see how to use full-text search in Rowy.

2. Managing The Search Index

A service like MeiliSearch offers full-text search by indexing documents in a dedicated database and returning this index to client apps. Indexing documents usually requires dedicated processes to create and maintain every time a document is created, updated, or deleted.

But with Rowy, you don't need to worry about maintaining the search index manually: Rowy handles all of that for you automatically. Whenever the database changes, Rowy syncs the changes with MeiliSearch's search index.

This way, you can focus on building your app. And the best part is that since Rowy syncs with Firebase, you can search any Firebase data automatically as well both inside and outside Rowy's UI.

3. Using Full-Text Search

As previously explained, you can use full-text search right away from enabled Rowy tables:

Additionally, you can directly call MeiliSearch’s API from any front-end client (for example, built with React):

const collection_name = 'countries'

fetch(`${MEILISEARCH_INSTANCE_URL}/indexes/${collection_name}/search`, {
    method: 'POST',
    headers: {
        'Content-Type': 'application/json',
        'Authorization': `Bearer ${MEILISEARCH_MASTER_KEY}`
    }, 
    body: JSON.stringify({
        q: 'spain'
    })
})

Which will return a JSON response containing the search results, ready to parse:

{
  "hits": [
    {
      "id": 2770,
      "country_name": "Spain",
      ...
    },
    ...
  ],
  "offset": 0,
  "limit": 20,
  "estimatedTotalHits": 976,
  "processingTimeMs": 35,
  "query": "spain"
}

Join Our Discord Community

That's a wrap. Wasn't too hard, right? Just connect MeiliSearch to Rowy and things just take care of themselves.

If you'd like to see more of the search feature in action, have a look at our Youtube video on the subject:

If you have any questions, feel free to join our Discord community and ask away!

Get started with Rowy in minutes

Continue reading

Browse all