I am trying to make an android application with firebase, I want to use the search function on firebase using startAt(). But the result confuses me.
I have data with such a database.
{
"siswa" : {
"100" : {
"id" : 100,
"nama" : "Sucipto"
},
"101" : {
"id" : 101,
"nama" : "Tomo"
},
"102" : {
"id" : 102,
"nama" : "Fitri"
},
"103" : {
"id" : 103,
"nama" : "Sumini"
},
"104" : {
"id" : 104,
"nama" : "Eko"
},
"106" : {
"id" : 106,
"nama" : "Sulastri"
}
}
}
My request example
final FirebaseDatabase database = FirebaseDatabase.getInstance();
final DatabaseReference siswaRef = database.getReference("siswa");
Query suciptoQuery = siswaRef.orderByChild("nama").startAt("Sucipto");
Result:
D/Query Sucipto: Nama : Sucipto
D/Query Sucipto: Nama : Sulastri
D/Query Sucipto: Nama : Sumini
D/Query Sucipto: Nama : Tomo
I will try another test request
Query suciptoQuery = siswaRef.orderByChild("nama").startAt("Su");
Result: Same as above.
Another request:
Query suciptoQuery = siswaRef.orderByChild("nama").startAt("Tomo");
or
Query suciptoQuery = siswaRef.orderByChild("nama").startAt("To");
Result:
D/Query Sucipto: Nama : Tomo
I am looking for this topic on SO, but still have no solution.