0

I recently made a quotations reader app for Android. I use a firebase firestore to save data, everything is fine until I have to search for data. This is my object on firebase(a map)

{"name":{"vi":"","en":"Barack Obama"}}

This is my code:

firebaseAuthors
        .whereGreaterThanOrEqualTo("name.en", search)
        .get().addOnCompleteListener {
            val data = it.result!!.toObjects(Author::class.java)
            Log.wtf("TAG", "data: $data")
        }

It doesn't work as I expected. When I type Barack it can find Barack Obama but if I type Obama it will not get any results. I want to search contains in a string that mean when I type a word, any sentence containing that word will be found. In this case, I want to find Barack Obama by typing any word in author name and regardless of upper case or lower case.

I aloso try this code:

firebaseAuthors
        .whereGreaterThanOrEqualTo("name.en", search)
        .whereLessThanOrEqualTo("content.en", search)
        .get().addOnCompleteListener {
            val data = it.result!!.toObjects(Author::class.java)
            Log.wtf("TAG", "data: $data")
        }

but it's not work. I also try to follow this video but it's not work too. Some one can help me. Thank you so much.

Hoàng Vũ Anh
  • 647
  • 1
  • 8
  • 24
  • Firestore does not support substring queries that are not prefixes. It also does not support "full text" search, which is a different thing. For that, they formally recommend Algolia. – Doug Stevenson Mar 07 '21 at 04:31
  • I think you might be interested in [this](https://stackoverflow.com/questions/49596610/is-it-possible-to-use-algolia-query-in-firestorerecycleroptions/49607796). – Alex Mamo Mar 08 '21 at 09:16

0 Answers0