I am trying to filter my Firebase data, my dataset is complex but here is a sample. I am able to retrieve data just fine but I am unable to filter that data any further using the Firebase queries. Here is a sample dataset:
Here is my query:
private double locStart;
private double locEnd;
Firebase mRef;
Firebase mRef1;
mRef = new Firebase("https://test.firebaseio.com/");
mRef1 = mRef.child("test");
final Intent intent = getIntent();
final Inputs inputs = (Inputs) intent.getSerializableExtra("inputs");
locStart = inputs.getLocLat() - 0.008983;
locEnd = inputs.getLocLat() + 0.008983;
Query filterData = mRef1.orderByChild("locLat").startAt(locStart).endAt(locEnd);
filterData.addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
Match matchd = dataSnapshot.getValue(Match.class);
Offer.setText(matchd.getfbName());
}
@Override
public void onCancelled(FirebaseError firebaseError) {
}
});
The reference mRef1 retrieves data perfectly, its only when I apply the query to it is when it retrieves null values, the data certainly matches the query, I have even hard coded the values but that does not seem to work either.
Am I missing something I should have setup on the Firebase console? I did setup an index and that solved a warning in my log which was suggesting me to set one up on the field meaning that Firebase is recognising the field and the index as well.