简体   繁体   English

如何在 Firestore 数据库中搜索?

[英]How to search in Firestore database?

I am using this way to search for users in firestore database and I think that it is inefficient way , because it give unrelated results , for example if I type 'k' it give me results does not contain 'k' at all like the image below .我正在使用这种方式在 firestore 数据库中搜索用户,我认为这是一种低效的方式,因为它给出了不相关的结果,例如,如果我输入“k”,它给我的结果根本不包含“k”,就像图像一样以下 。

 var query = firestore
    .collection("users")
    .where('name', isGreaterThanOrEqualTo: customer)
    .get()
    .asStream();

在此处输入图片说明

any suggestion please ?!请问有什么建议吗?!

When you are using the following call:当您使用以下调用时:

.where('name', isGreaterThanOrEqualTo: customer)

It means that you are searching the database for the documents in which the "name" property holds a value that is greater than the one you are typing.这意味着您正在数据库中搜索“name”属性包含的值大于您键入的值的文档。 In this particular case, both "Omar" and "Second Omar" are present in the result-set, since each one of them starts with a letter that is alphabetically ordered after "k".在这种特殊情况下,“Omar”和“Second Omar”都出现在结果集中,因为它们中的每一个都以一个字母开头,该字母按字母顺序排列在“k”之后。 In fact, all capital letters are present in alphabetical order after the lower-case letters.事实上,所有大写字母都按字母顺序出现在小写字母之后。 Remember that the search is performed lexicographically .请记住,搜索是按字典顺序执行的。

If you are looking for a full-text search, please note that Firestore doesn't provide one.如果您正在寻找全文搜索,请注意 Firestore 不提供。 As @Dharmaraj mentioned in his comment, you should use a third-party solution.正如@Dharmaraj 在他的评论中提到的,您应该使用第三方解决方案。 You can also find more info in my answer from the following posts:您还可以在我的以下帖子的回答中找到更多信息:

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM