Firestore text search containing keyword Flutter

我只是一个虾纸丫 提交于 2021-01-29 05:24:55

问题


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

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!


回答1:


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

Few Risks with current flow:

  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

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.

Solution: https://firebase.google.com/docs/firestore/solutions/search



来源:https://stackoverflow.com/questions/65769237/firestore-text-search-containing-keyword-flutter

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!