0

I'm trying to make search in my database, by using search bar in Client, and creating an query, that will be in Adapter(FirebaseRecyclerAdapter)

Problem is, that user could search in all parametrs(item or country for example) but i couln't find the solution to find all children

Query. For example user wrote "hat" in search bar, and it'll work if i select "item" in orderByChild, but if he wrote "Germany" it wouldn't work

Query query = reference.orderByChild("item").equalTo("hat");

database

{
    "shop": {
        "0": {
            "item": "hat",
            "country": "Germany"
        },
        "1": {
            "item": "hat",
            "country": "America"
        },
        "2": {
            "item": "shoes",
            "country": "Germany"
        }
      }  
}

So how to make search in All Children? In "item" and in "country" at the same time? Thanks in advance.

Constantin Beer
  • 5,447
  • 6
  • 25
  • 43
T5un4m1
  • 44
  • 4
  • 2
    You cannot query multiple fields. You could prompt your user for what they are using (`item` or `country`) – theblindprophet Jun 08 '17 at 14:59
  • It sounds like a categorization problem, where you treat both `item` and `country` (and possibly other properties) as a category. You need a reverse index to allow searching those. See my answer here http://stackoverflow.com/questions/40656589/firebase-query-if-child-of-child-contains-a-value – Frank van Puffelen Jun 08 '17 at 16:19

0 Answers0