Firebase queryEqualToValue
returns items EQUAL to the specified key or value. How can we query for items PARTIALLY MATCH to the specified key or value?
Asked
Active
Viewed 1,348 times
0

Alex
- 881
- 2
- 10
- 24
-
1As iOSGeek's answer shows, you can do "starts with" type queries with Firebase. But broader `LIKE` searches are not possible. See http://stackoverflow.com/questions/22506531/how-to-perform-sql-like-operation-on-firebase – Frank van Puffelen Jul 25 '16 at 15:09
-
@frankvanpuffelen Yes, I want to do a LIKE search, I've read the blog post, but the blog post is in 2014, so today, there is still no existing firebase method or feature I can use to accomplish LIKE search? – Alex Jul 25 '16 at 15:22
-
There are no LIKE searches directly in Firebase. However, if you structure your data correctly, you can perform [Wildcard Searches](http://stackoverflow.com/questions/36365157/wildcard-query-on-firebase/36366619#36366619). Which is similar. – Jay Jul 25 '16 at 17:37
-
Oh, and the answer to this question is also applicable for LIKE type searches. [Real Time Searching](http://stackoverflow.com/questions/36870425/swift-how-can-i-use-shouldchangetextinrange-with-firebase-for-real-time-sear/36872475#36872475) – Jay Jul 25 '16 at 17:44
1 Answers
3
We can combine startAt() and endAt() to limit both ends of our query. The following example finds all dinosaurs whose name starts with the letter "b":
let ref = Firebase(url:"https://dinosaur-facts.firebaseio.com/dinosaurs")
ref.queryOrderedByKey().queryStartingAtValue("b").queryEndingAtValue("b\u{f8ff}")
.observeEventType(.ChildAdded, withBlock: { snapshot in
println(snapshot.key)
})
The f8ff character used in the query above is a very high code point in the Unicode range. Because it is after most regular characters in Unicode, the query matches all values that start with a b.

iOSGeek
- 5,115
- 9
- 46
- 74
-
-
-
That's . Source - http://www.fileformat.info/info/unicode/char/f8ff/index.htm – Gaurav Chandarana Apr 06 '18 at 08:19