Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use Algolia in Android with Firebase content

I made an app where anyone can sell a product: you set its details and then I save it in Firebase.

On the client side (Android app) I want to be able to search for products using plain text.
I think the best way is by using Algolia but I really have no idea how to set-it up. Your help will be appreciated!

like image 593
Cybdom Avatar asked Dec 19 '22 09:12

Cybdom


1 Answers

There are actually two topics in your question: how can one link Algolia to a Firebase database and how can one build an Android app with Algolia. I'll cover both in my answer.

How to link Algolia to Firebase

You will need to use a scripting language to import your existing data into Algolia and to sync the changes when your data is updated. Algolia has a guide to help you do so using Node.js.

You don't need to be experienced with Node.js to do it! Have a look at this question where an Android developer like you with no prior experience of Node.js just followed the guide:

In the first gathering of data, I just copied the integration code, did the necessary changes and ran it on Windows terminal: the data is now imported from Firebase to Algolia.

You simply need to:

  • Copy the code samples from Algolia's Firebase guide
  • Replace the credentials with yours
  • Run the scripts from your computer (if you never ran js scripts locally, search for a Node.js beginner's guide like this or this)

Once your data is imported in Algolia, you can move on to step 2:

How to use Algolia in your Android app

For building your search interface with Algolia, the recommended tool is InstantSearch Android. It's a toolbox that provides you plug-and-play components to build your search interface quickly: InstantSearch will handle all the network-related issues, the data-binding, and many other things so you can focus on what's specific to your app.

You can have a look at InstantSearch Android's demo apps which will show you examples what you could build using this tool, like this Media demo:

Media app example

Algolia also provides an Android API Client for building apps. It lets you interact at a lower level with Algolia: you send the requests, get the results as JSONObject and decide what you want to do with it.

Most projects should use InstantSearch Android as it is built to make your development easier and faster (and it actually uses the Android API Client under the hood!)

like image 116
PLNech Avatar answered Jan 06 '23 16:01

PLNech