Firebase 如何在扑动火场中进行空间搜索

Firebase 如何在扑动火场中进行空间搜索,firebase,flutter,google-cloud-firestore,Firebase,Flutter,Google Cloud Firestore,我想通过firebase数据库从中搜索,但当名称之间出现空格时,它根本不起作用。那我现在该怎么办呢。。它在空间被给予之前就起作用了 代码: 尝试添加以下内容: .where("searchIndex", isGreaterThanOrEqualTo: searchString) //String comparison .where('searchIndex', isLessThan: searchString + 'z') //Shows all results until

我想通过firebase数据库从中搜索,但当名称之间出现空格时,它根本不起作用。那我现在该怎么办呢。。它在空间被给予之前就起作用了

代码:


尝试添加以下内容:

.where("searchIndex", isGreaterThanOrEqualTo: searchString)  //String comparison
.where('searchIndex', isLessThan: searchString + 'z') //Shows all results until the letter ends with a Z, so this should include spacebar

尝试添加以下内容:

.where("searchIndex", isGreaterThanOrEqualTo: searchString)  //String comparison
.where('searchIndex', isLessThan: searchString + 'z') //Shows all results until the letter ends with a Z, so this should include spacebar

嗨,请让我知道我的回答是否解决了你的问题,谢谢:)你说的“名字之间的空格”是什么意思?您能否提供一些不符合预期的示例?例如,数据库的一个字段包含字符串“Frank Van puffelen”。现在,当我在搜索框中键入Frank时,这里没有问题,但是在Frank之后,如果我按空格键,那么我键入Van,它将无法在搜索中工作。我使用下面的代码搜索…stream:(searchString==null | | searchString.trim()==“”)?Firestore.instance.collection('ebook').snapshots():Firestore.instance.collection('ebook').where('searchIndex',arrayContains:searchString)/.where('organization',isEqualTo:searchString.).snapshots(),请不要在注释中发布代码,因为很难阅读;在问题中包含代码。Firestore没有部分字符串搜索,因此问题不清楚。如果数组包含字符串Frank Van Puffelen,则会对字符串Frank执行搜索。找不到匹配项。或者,您的意思是将字符串中的单个单词作为数组中的不同元素进行分布?e、 g[0]弗兰克[1]范[2]帕夫伦?你也可以使用大于或小于的创造性代码进行部分字符串搜索,但我在问题中没有看到该代码。嗨,请告诉我我的答案是否解决了你的问题,谢谢:)你说的“名字之间的空格”是什么意思?您能否提供一些不符合预期的示例?例如,数据库的一个字段包含字符串“Frank Van puffelen”。现在,当我在搜索框中键入Frank时,这里没有问题,但是在Frank之后,如果我按空格键,那么我键入Van,它将无法在搜索中工作。我使用下面的代码搜索…stream:(searchString==null | | searchString.trim()==“”)?Firestore.instance.collection('ebook').snapshots():Firestore.instance.collection('ebook').where('searchIndex',arrayContains:searchString)/.where('organization',isEqualTo:searchString.).snapshots(),请不要在注释中发布代码,因为很难阅读;在问题中包含代码。Firestore没有部分字符串搜索,因此问题不清楚。如果数组包含字符串Frank Van Puffelen,则会对字符串Frank执行搜索。找不到匹配项。或者,您的意思是将字符串中的单个单词作为数组中的不同元素进行分布?e、 g[0]弗兰克[1]范[2]帕夫伦?此外,您还可以使用大于和小于的创造性代码进行部分字符串搜索,但我在问题中没有看到该代码。答案不错,尽管以“z”结尾的代码有限。试试
let endingWith=searchString+“\u{f8ff}”
这样就可以了。where('searchIndex',isless:endingWith)来自我的快速答案@Jay谢谢Jay这是一个更好的答案:)除了flatter不理解“let”这个词。因此,在本例中,它将是以良好答案结尾的字符串,尽管以“z”结尾是有限的。试试
let endingWith=searchString+“\u{f8ff}”
这样就可以了。where('searchIndex',isless:endingWith)来自我的快速答案@Jay谢谢Jay这是一个更好的答案:)除了flatter不理解“let”这个词。所以在这种情况下,它将是以