Firebase应用搜索function – 使用字符串正则表达式进行查询

我正在将应用程序从Parse移植到Firebase,我以前能够使用matchesRegex进行查询并将搜索放入"(?i)\(searchBar.text!)" 。 通过这样做,用户可以搜索“p”并且数据库将返回(例如)“人”,“人”,“锅”等。

我似乎找不到使用Firebase查询的方法,允许用户搜索String的一部分,Firebase查找数据库中的子字符串。

我在用:

 databaseReference.child("Schools").queryOrderedByKey().queryEqualToValue("(?i)\(searchBar.text!)").observeSingleEventOfType(.Value, withBlock: { (snapshot) in for childSnapshot in snapshot.children { print("SANP \(childSnapshot)") } }) { (error) in print(error) } 

如果我这样做,则不会打印任何内容。 我知道上面的代码是有效的,如果我搜索一个特定的字符,该字符与数据库中的字符相同。

如何使用Firebase数据库中的部分字符串进行搜索?