0

I have this data structure:

messages:
{
  userId1:{
    messageKey1:{
      userKey: ...
      text: ...
      (...)
    },
    (...)
  }
  (...)
}

I would like to indexOn userKey. Is it possible to do so or should I denormalize my data?

Thank you for helping.

luk2302
  • 55,258
  • 23
  • 97
  • 137
Eric Hth
  • 79
  • 9
  • Indexes in Firebase currently are on-level deep. So if you need deeper levels or multi-value, you will need to maintain an index manually. This has been asked before, so I'll mark as a duplicate. – Frank van Puffelen May 15 '15 at 18:13
  • 1
    possible duplicate of [Using .indexOn with nested keys in Firebase](http://stackoverflow.com/questions/27179094/using-indexon-with-nested-keys-in-firebase) – Frank van Puffelen May 15 '15 at 18:15
  • Thank you for the answer. I think a two level indexing would be a great plus since it is only possible so far to query with on key condition. It would be indeed possible to filter the data on the client side but then in some case much more data would be downloaded making the overall experience less responsive. – Eric Hth May 15 '15 at 21:29
  • However is an index really necessary if the dataset is about 10K items? – Eric Hth May 15 '15 at 21:30
  • Btw how would it be possible to build an index manually? would it be by using elastic as describe here : https://www.firebase.com/blog/2014-01-02-queries-part-two.html ? Thank you for helping. – Eric Hth May 15 '15 at 21:38
  • See https://www.firebase.com/blog/2013-04-12-denormalizing-is-normal.html Despite the disclaimer at the top, the content is still relevant if you need to programmatically need to create your own index. – Frank van Puffelen May 16 '15 at 00:57

0 Answers0