0

I wann make app wich search more than once thing from my firebase real-time database for recycler view.

My database looks like

Node
.
.Item
  .
  ...pushKey()
       .
       . Name:- "iodex"
       . Type:- "balm"

Now,i know how to search only one thing let say Name. By

database.getRefrence().child("Item"). orderByChild ("Name"). startAt(...).endAt(...);

But i want to search both Name and Type simultaneously, So how can i do? Thank you

Fussycat
  • 3
  • 2
  • That's not possible with Realtime Database without making multiple queries. You might want to consider switching to Firestore if you want [compound queries](https://firebase.google.com/docs/firestore/query-data/queries#compound_queries) using logical AND among multiple fields in documents. – Doug Stevenson Feb 26 '22 at 04:48
  • @DougStevenson so in firestore database ,is it possible? Beacuse i am not familiar with firestore – Fussycat Feb 26 '22 at 04:50
  • As Doug suggested, if you consider at some point in time to try using [Cloud Firestore](https://firebase.google.com/docs/firestore/), then I think that [article](https://medium.com/firebase-tips-tricks/how-to-filter-firestore-data-cheaper-705f5efec444) might help. – Alex Mamo Feb 26 '22 at 09:55
  • Firebase Database queries can only order/filter on a single property. In many cases it is possible to combine the values you want to filter on into a single (synthetic) property, like `"Type_Name": "balm_iodex"` and then search on that. For a longer example of this and other approaches, see my answer here: http://stackoverflow.com/questions/26700924/query-based-on-multiple-where-clauses-in-firebase – Frank van Puffelen Feb 26 '22 at 15:38

0 Answers0