I would like to perform wildcard queries on a Firebase database, and do not know whether the libraries support this. - (my guess it does not.)
I want an optimal solu
Firebase Database queries can order/filter data based on the object's keys (e.g. id_001123
), their values (doesn't apply in your case), or the value of a child property (e.g. the fact that name
= "java"
).
For each of these Firebase can match items that have a specific value you specify, items starting at a value you specify, or items ending at a value you specify.
So you can create a query matching the item named objective-c
with:
ref.child("user_id").orderByChild("name").equalTo("objective-c")
Or you can create a query matching id_001124
and id_001125
with:
ref.child("user_id").orderByKey().startAt("id_001125")
Or simply getting all items starting with id_0011
:
ref.child("user_id").orderByKey().startAt("id_0011")
Or you can create a query matching id_001123
and id_001124
with:
ref.child("user_id").orderByKey().endAt("id_001124")
Firebase Database cannot filter based on the end of a value. So there is no way in your current data structure to get all items whose key ends in a 4
.
Please read more about Firebase Database queries here: https://firebase.google.com/docs/database/android/lists-of-data#sorting_and_filtering_data
And see some of the many previous questions about searching for FirebaseL