1

enter image description here from client side how can i search by businessName in firebase all record like when i write ka then kashif, kaleem, related data will be show to me.

Chris
  • 7,830
  • 6
  • 38
  • 72
  • 1
    You can query startingAt("ka").endingAt("ka\uf8ff"") and that will return all of the businesses starting with ka; kaschif, kaleem etc. – Jay Nov 08 '17 at 19:08
  • The *\uf8ff* component is a character high in the unicode table, so it's essentially querying for starting "ka" and ending "ka"+high unicode char. It gives some flexibility in queries for finding words starting with a specific string. Substring searches are a bit more complex but if they are single words, can be done by [brute force](https://stackoverflow.com/questions/36870425/swift-how-can-i-use-shouldchangetextinrange-with-firebase-for-real-time-sear/36872475#36872475) or if you want a lot of flexibility for larger strings [ElasticSearch](https://www.elastic.co/products/elasticsearch) – Jay Nov 08 '17 at 19:46

1 Answers1

1

Unfortunately, Firebase doesn't support this (yet?). You'd have to download all data and make your own local search function. Firestore has improved on Firebase's query ability, but only a little. All-in-all, querying power is Firebase's fatal weakness.

xon52
  • 696
  • 4
  • 12
  • 3
    This answer is not accurate. You can query startingAt("ka").endingAt("ka\uf8ff"") and that will return all of the businesses starting with ka; kaschif, kaleem etc. Also, see [this answer](https://stackoverflow.com/questions/45054550/firebase-database-how-to-perform-a-prefix-wildcard-query) for some other options. – Jay Nov 08 '17 at 19:06
  • 1
    @Jay wow, your solution worked, could you explain `\uf8ff`, is this indicating regex? Also, this solution only works if the letters match from the start. Like if i write 'u', it won't search for `Junaid`, `Qumber`... – Mohammad Kashif Sulaiman Nov 08 '17 at 19:26