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.