0

In the database child product and this child has several children. I want to click search and have all children searched, not only one child. For example: The search is by description or price and not on the name only.

DatabaseReference reference = FirebaseDatabase.getInstance().getReference().child("Products");


FirebaseRecyclerOptions<Products> options = new FirebaseRecyclerOptions.Builder<Products>()
                .setQuery(reference.orderByChild("pname").startAt(searchinput), Products.class)
                .build();
Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807
mhd yay
  • 1
  • 1
  • Can you add your database structure and explain more what you want to achieve? – Md. Asaduzzaman Jan 25 '20 at 19:05
  • – Md. Asaduzzaman I want to search in more than one place orderByChild("pname") i want orderByChild("description") and orderByChild("price") Do you know what I want to do? – mhd yay Jan 25 '20 at 20:11
  • You can't use more than one `orderByChild` in query of firebase. What you can do is just add one `orderByChild` in your query and implement another one in client side after getting data – Md. Asaduzzaman Jan 25 '20 at 20:15
  • 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. So in your case you could have a property `"pname_description": "value1_value2"` and order/filter on that. For a longer example of this and other approaches, see my answer here: https://stackoverflow.com/questions/26700924/query-based-on-multiple-where-clauses-in-firebase – Frank van Puffelen Jan 25 '20 at 21:12

0 Answers0