Suppose that I have a UISearchBar and I must perform a search of objects according to its names. But I want to perform this search by substrings in realtime. The problem is that there is not a method in the Firebase SDK for iOS to perform the search by substrings as "queryContainingSubstring:" or something.
In this post: Swift - How Can I use 'shouldChangeTextInRange' with Firebase for real time searching?, I have found two ways:
Broke the name of the object and then querying if the object contains that substring, i.e:
people { person_0 { first_name //First name is Ted from above T: true Te: true Ted: true ed: true d: true e: true } person_1 { first_name //First name is Teddy from above T: true Te: true Ted: true etc } }
Load all the data from Firebase into an array and NSPredicate search (or other methods) through the array.
The problem with the first way is that it can use a considerable space in the database when I have many objects. The problem with the second way is, for example, suppose that I have many data in the database, I'm pretty sure that we could have memory problems.
Is there any way to perform this search over the name of the object directly in the database? Have you any trick to perform this search?
Sorry for my English.