0

Edit: I want to filter all the post liked by someone using their phone number My app was working since 3 years earlier i got warning in console about indexOn issue and i have added security rules as per instructed, now when i have updated firebase sdk and also now I'm using addOnCompleteListener instead of valueEventListener now some part of my app not working and now I'm getting exception about indexOn enter image description here

I don't how to add index for this kind of key as it keeps changing as per user. if I hardcode users phone number then it is working but I can't add keys for every user as there are few thousand user so please let me know what i can do. here are few attachments about database, query and rules

database enter image description here

query

FirebaseDatabase.getInstance()
                .getReference("2 line poetry").orderByChild(number).equalTo("heart");

Rules(currently used which works on previous version) enter image description here

Rules(Hardcoded version which is working in new version) enter image description here

I want to make this rule dynamic like using variable $phone or something, I have read almost all threads but didn't found any answer

Sadique Khan
  • 230
  • 3
  • 9
  • Your data structure makes it easy to find phone numbers for a given key, but it does not make it easy to find keys for a given phone number. To allow this you will need an additional data structure that maps back the phone numbers to the keys they liked. For more on this see the questions I linked. – Frank van Puffelen Mar 08 '22 at 22:00
  • Note that this is not a change in existing behavior though, and has always been the case (check the dates on the questions I linked). If something changed in how your app functions, you most likely added/changed code, or potentially just updated the SDK version. If it's the latter case, that would indicate a regression. I somewhat doubt that though, but it *is* always possible of course, so I'd love to see a repro in that case. – Frank van Puffelen Mar 08 '22 at 22:03
  • thanks frank for quick reply, since my database is huge and app is deployed for almost 3 years I cannot change structure of database as it affects functionality of the app and will cause problems. can you please tell me is there any thing possible to index my query without changing data structure. – Sadique Khan Mar 09 '22 at 10:40
  • If there was a way, it would have applied to those questions I linked to. You will either have to add the additional structure, all load all data and do the filtering in your application code. – Frank van Puffelen Mar 09 '22 at 15:01

0 Answers0