包含关键字Flutter的Firestore文本搜索 [英] Firestore text search containing keyword Flutter

查看:41
本文介绍了包含关键字Flutter的Firestore文本搜索的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我打算为文档的 String 名称字段提供全文搜索功能,但是根据我所做的研究,似乎无法使用firestore搜索文本,于是我提出了一个解决方案,即创建一个新的数组字段以将关键字存储在文档中,例如

i was planning to have a full text search feature for the String name field of my document, but from the research i have done , it seems like searching text with firestore is not possible, then i come up with solution which is creating a new array field to store keyword in document, like this

然后我使用arracVontains调用它,并使用searchedKeyword作为用户输入的文本

and then i called it using arracVontains, with searchedKeyword as the inputted text from user

_firestore
        .collection(itemOrderPath)
        .where("keyword", arrayContains:searchedKeyword)

现在,我很犹豫是否可以这样做(会对我的应用产生巨大影响)吗?还是有更好的方法来做到这一点?谢谢!

Now, i'm quite hesitant on wether it is okay to do it like this(will there be huge impact on my app)? or is there any better way to do this? Thank you!

推荐答案

我是同一职位,之前,我决定使用Algolia + Firestore进行全文搜索

I was in the same position, before, I decided to go with the Full-text search using Algolia + Firestore

当前风险很小:

  1. 需要更多的手动工作.创建/更新
  2. 字符串数据区分大小写
  3. 您在这里为文档增加了更多的权重.可能会影响性能
  4. 对于单个关键字搜索 array-contains 就足够了;但是,对于多关键字搜索,您必须使用 array-contains-any ,但这没有什么限制.
  5. 等,等等
  1. More manual work needed. Create / Update
  2. String data is case sensitive
  3. Here you are adding more weight to your document. It may affect the performance
  4. For single keyword search array-contains would be enough; However for multi keyword search you have to go with array-contains-any, but it has few limitations.
  5. etc, etc

我尝试了与您现在使用的相同的解决方案.但是,由于一些限制,我选择了此 Algolia 解决方案.对我来说,这种解决方案似乎有点昂贵.但是在初始阶段,我们可以解决这个问题.但是最后,您必须根据应用程序的需求来决定.

I tried the same solution that you are following now. However, due to few limitation, I picked up this Algolia solution. For me, this solutions seems bit costly; however at initial stage we could manage this. But at the end, you have to decide based on your application's requirement.

解决方案: https://firebase.google.com/docs/firestore/solutions/search

这篇关于包含关键字Flutter的Firestore文本搜索的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆