0

i have a question. If i want to upload a large array of strings (which would basically category tags for an autocomplete searchview in an Android app) , we are talking about 20.000 or so Strings, passed as an

HashMap<String,String> tags = new HashMap<>();
tags.add(tag,category);
mDatabase.child("categories").setValue(tags);

to the Firebase Realtime database. This implementation works, but since we are talking about a large number of nodes , Firebase switches off realtime-mode and switches to read-only. Is there any way of structuring the data to avoid this? I'm thinking of splitting the tags into sub-nodes, ordered by letters.

Something like :

categories
  - a
    - tag - category
    - tag - category 
  - b 
    - tag - category
    - tag - category

etc.

Whould this avoid the switch to Read-Only mode in the Firebase Console?

Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807
Alex
  • 127
  • 3
  • 12
  • A list of categories should not be stored as an array. It's a set, so should be stored as such. See my answer here: http://stackoverflow.com/questions/40656589/firebase-query-if-child-of-child-contains-a-value – Frank van Puffelen Feb 08 '17 at 20:27
  • Aside from that read-only mode is activated when you have a large number of child nodes and/or a large data size the location where you open the Firebase Database console. If you want to ensure realtime mode stays active, reduce the number of nodes and data size. – Frank van Puffelen Feb 08 '17 at 20:34
  • @Frank van Puffelen , thanks for the tips, though i have a newer ideea. I only need to download this suggestions dictionary once every 24 hours for my app, so i actually don't need the realtime part of the FB database. I'm thinking of storing the categories inside an xml on Firebase Storage (not the Realtime Database) , and using an ASink task pulling it down once every 24h, and inserting into an SQL db. Am i over-complicating things much by doing this? – Alex Feb 08 '17 at 20:53
  • If the users can modify the suggestions, indeed Firebase Storage is a good spot. If only you modify it, you should consider Firebase Hosting. See [my answer here](http://stackoverflow.com/questions/37482907/firebase-differences-between-realtime-database-and-file-storage). – Frank van Puffelen Feb 08 '17 at 21:13
  • @ Frank van Puffelen Nope, they cannot, and should not. I was thinking of FIrebase Hosting too, i also need to store some images, currently in Storage, but i think i'll move those to Hosting too, since they also do not need to be modified. Thanks a lot for the answer, i think i'm going with the route, since it makes a lot more sense. – Alex Feb 08 '17 at 21:21
  • Good to hear Alex. I'm going to close the question as a duplicate, because you went that route. – Frank van Puffelen Feb 08 '17 at 23:07

0 Answers0