I want to orderby shopId but it returns:
"error" : "Index not defined, add ".indexOn": "shopId", for path "/Products", to the rules".
Would appreciate any help thanks!

Rules :
{
"rules": {
".read": "now < 1609966800000", // 2021-1-7
".write": "now < 1609966800000", // 2021-1-7
"Products":{
"Records":{
".indexOn":["shopId"]
}
}
}
}
Pyrebase code:
result = db.child("Products").order_by_child("shopId").equal_to(shopId).get()
Firebase Realtime Database can only filter the direct child nodes on which you run the query. The value which you order/filter on must be at a fixed path under each direct child node.
In your data structure you seem to have two unknown keys:
UIDandunique_recordid. This means you cannot query forshopIdfromProducts.You can query the records for a single user:
But you can't do the same query on all of
Productsas the path of theshopIdproperty is not the same for all child nodes ofProducts.Also see Firebase Query Double Nested
If you want to query for records with a specific
shopId, you'll need in your database a flat list of exactly those nodes.On this data you can then query for
productIdand look up the other data, including the UID that is now duplicated for each record.