0

I'm trying to user firebase realtime database and facing now warning message I can't solved it

Using an unspecified index. Your data will be downloaded and filtered on the client. Consider adding '".indexOn": "sharingIds/4jjf24uurjkfJDGLS"' at MedicalCaeses to your security and Firebase Database rules for better performance

structure


MedicalCaeses { 
           urjkfJDGL
           {
              name: "Ali"
              sharingIds : {"4jjf24uurjkfJDGLS": true,"jsaiwn22Ad2GLS": true}
           }
}

.indexOn

"MedicalCaeses":{
        "sharingIds":{
            ".indexOn": ".value"
      }
    },

Query

await FirebaseDatabase.instance
        .reference()
        .child('MedicalCaeses')
        .orderByChild('sharingIds/4jjf24uurjkfJDGLS')
        .equalTo(true)
        .once();

result

W/PersistentConnection( 8104): pc_0 - Using an unspecified index. Your data will be downloaded and filtered on the client. Consider adding '".indexOn": "sharingIds/4jjf24uurjkfJDGLS"' at MedicalCaeses to your security and Firebase Database rules for better performance

I/flutter ( 8104): <Data Read> {xxxxx: {sharingIds: {4jjf24uurjkfJDGLS: true}, name: Ali}}
Mahmoud Niypoo
  • 1,598
  • 5
  • 24
  • 41
  • Your current data structure makes it easy to find the sharing IDs for a given case, but not the cases for a given sharing ID. To allow that, consider storing a separate top-level node where you start with each sharing ID and then store it's medical case IDs. For more on this see, https://stackoverflow.com/questions/40656589/firebase-query-if-child-of-child-contains-a-value – Frank van Puffelen Jul 27 '21 at 20:26
  • @FrankvanPuffelen can you provider an example for this structure ? – Mahmoud Niypoo Jul 28 '21 at 10:29
  • There's an example in my answer to the question I linked. In there we have `chatroomUsers` and `userChatrooms` top-level nodes. In your case it might be `MedicalCaeses` [sic] that you already have and a new `sharingIDs` top-level node, where you store the medical case IDs for each sharing ID, similar to what we do for users and chat rooms in the link. – Frank van Puffelen Jul 28 '21 at 13:58

0 Answers0