Case insensitive looking Firebase

0

I'm using the searhcview of the toolbar to search for recyclerview items, the search works, but the Firebase query differentiates between upper and lower case and accented words. I would like Case Insensitive to search for Firebase.

Ex: I searched the word Sao Paulo and typed in the sao paulo search.

In the recyclerview I would like the word São Paulo to appear with capital letters and also with ã.

As my query is only appears São Paulo if I put the word São Paulo in the search.

 Query Q = organizacao.orderByChild("nomeOrganizacao").
 startAt(newText).endAt(newText + "\uf8ff");

    
asked by anonymous 29.01.2018 / 10:40

1 answer

0

At the moment Firebase has no way to do case insensitive searches. But an alternative for you to have the desired result would be: Add a second field that stores the Organization name all in lowercase:

"01":{
    "nomeOrganizacao":"São Paulo",
    "nomeMinusculo":"são paulo",
    ...
}

And at the time of fetching the data, you transform the String that comes from SearchView to lowercase and query through that field:

newText = newText.toLowerCase();
Query Q = organizacao.orderByChild("nomeMinusculo").
 startAt(newText).endAt(newText + "\uf8ff");
    
29.01.2018 / 20:45