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