0

I have 2 questions here.

  1. How to make the search for query that second word?

ex: Big Apple.

When user search Apple, and it still will display the result.

I already make a research, most of the search query only search for the first word.

  1. How to retrieve data from main child to relative view when we have 2 childs?

As you can see at the below, there are 2 types of database. What I found out is, we have to make new upperCase BUT in the main.

ex:

{
  "karangan" : {
    "karanganuid" : {
      "main": {
        "title": "Big Apple",
        "titleUpperCase": "BIG APPLE"
      }
    }
  }
}

Can we do like this? If we can, how to retrieve the data?

{
  "karangan" : {
    "karanganuid" : {
      "main" : {
        "title" : "Big Apple"
      },
      "upperCase" : {
        "titleUpperCase" : "BIG APPLE"
      }
    }
  }
}
Alex Mamo
  • 130,605
  • 17
  • 163
  • 193
Ticherhaz FreePalestine
  • 2,738
  • 4
  • 20
  • 46

1 Answers1

1

How to make the search for query that second word?

Firebase realtime database does not support native indexing or search for text fields in database properties. So there is no contains() method for that.

Additionally, downloading an entire node to search for fields client-side isn't practical at all. To enable full text search of your database data, I recommend you to use a third-party search service like Algolia or Elasticsearch.

If you consider at some point to try using Cloud Firestore, please see my answer from this post where I have explained how it works with Cloud Firestore but in the same way you can use it with Firebase realtime database.

Alex Mamo
  • 130,605
  • 17
  • 163
  • 193