I'll preface this by including existing (and useful) firebase data structure references:
https://www.firebase.com/blog/2013-04-12-denormalizing-is-normal.html
What's the best way of structuring data on firebase?
Firebase data structure and url
However, what I'm looking for is something more synonymous with MySQL's WHERE LIKE, i.e. the ability to return records that include a given substring.
Specifically, I want to provide users with a way to search all (public) users of an app (by username / name / email / phone / all of these).
I don't want to download all users and then use angular filters / alternative client side filtering, as this could become a large download as the user base scales (especially if the search is across multiple collections - e.g. username, name, email etc.)
I've considered using a tree structure, for example:
- users
- username
- a
- an
- and
- andy
- andr
- andre
- andrea
- andrew
- ann
- anne
Then I could reference users/username/a when a user types in 'a', users/username/a/an for 'an' etc. and effectively only reference a subset of the users based on the search term.
Considering the NoSQL nature, along with the advice to denormalise data and keep the structure flat, does this structure make sense?
Or, is there an alternative / better way to do a LIKE esque query?