1

i have a collection with name user and doc with doc id 'dos12'

and have data like this ({ number:2322012, name:'abc })

i am using

firestore().collection('user').orderBy('name')
            .startAt('abc)
            .endAt('abc + '\uf8ff')
.get()

This is case sensitive if i am searching Abc then it is not getting results. How can i make it non-case Sensitive so that i can get on search abc or ABC get same results. As well as how can make it if i search a letter b letter or c letter then also get results. Now if i search bc then not getting any result.

Thanks

underscore_d
  • 6,309
  • 3
  • 38
  • 64
Rover
  • 661
  • 2
  • 18
  • 39

1 Answers1

0

To support case-insensitive, you'll need to write a separate field like

db.collection("users").where("name", "==", "Abc")
db.collection("users").where("name_lowercase", "==", "abc")

Something similar to the following

firestore().collection('user').orderBy('username_lowercase')
    .startAt(username.toLowerCase())
   .endAt(username.toLowerCase() + "\uf8ff")

For Ref: Firestore-queries-still-case-sensitive and firestore-case-insensitive

Nooruddin Lakhani
  • 7,507
  • 2
  • 19
  • 39
  • i tried with the firestore().collection('user').orderBy('username_lowercase') .startAt(username.toLowerCase()) .endAt(username.toLowerCase() + "\uf8ff") but this is not working if i am searching ABC it just giving me data for ABC only – Rover Nov 06 '20 at 05:56