I wanna pull information from a Firebase Database but it's a case sensitive query, and i don't want it to be case sensitive, is there a way to make the query NOT case sensitive in Android Studio ,Here is the query code
DatabaseReference SearchRef = (DatabaseReference) FirebaseDatabase.getInstance().getReference().child("Child1").orderByChild("Child2").startAt(searchText).endAt(searchText + "\uf8ff"); // \uf8ff is a white space
Query Searchquery = Searchref;
Searchquery.addValueEventListener...
David Notik. Ok, so Firebase is case-sensitive so if you're users/Kai is not same as users/kai.
The character \uf8ff used in the query is a very high code point in the Unicode range (it is a Private Usage Area [PUA] code). Because it is after most regular characters in Unicode, the query matches all values that start with queryText .
You can create a unique key in Firebase database using push() and then add child nodes under that key. Now next time when you come to that activity, first check if parent node exists or not. If the node exists, save parent node key and use it to save new child nodes.
We can use HashMap.
When using Firebase Database
, that is the much you get to from orderByChild()
function. It returns data either ascending or descending order and you cannot customize your result with extended queries.
However, You can try a something else that may be a bit more expensive. Get all the children you want as an array, saving Child2 and its key. You can then change the string to upper case or lower case and access the desired result using the key.
The reference result would be
FirebaseDatabase.getInstance().getReference("Child1").child(key);
EDIT
To add on your logic, If you want "Dave" or "dave" to return Dave and dave
You can edit your query to startAt(text.toUppercase)
and endAt(text.toLowerCase+ "\uf8ff")
. This will return DAVE, Dave, dave etc
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With