Reputation: 13
I'm trying to add a feature in my app to search users by their name in Firebase, so I've tried to make a query that returns all the users where their name contains the search.
For example, if we have 5 users and their names are: "Bernard, Francois, Connard, Antoine, Penard" and the search is "nar", the query would return "Bernard, Connard, Penard". Does someone have an idea how to do the query? Or else a better idea to find the users?
Upvotes: 1
Views: 925
Reputation: 4623
Unfortunately, Firebase does not offer substring-match functionality. There are some hacks available with good thought on data structures and a bit of code work if you only want PREFIX based matches, but there is no operator for INFIX matches.
Your best option is to acknowledge that Firebase is an excellent database, but not an excellent search engine. There is nothing wrong with this - it does its actual job very well. When you need search, you will have the best results "pairing" it with an actual search engine such as ElasticSearch, Algolia, CloudSearch, etc.
Upvotes: 2